Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent default category to be reset when already defined during import #6651

Merged
merged 1 commit into from Oct 12, 2016
Merged

Conversation

firstred
Copy link
Contributor

Questions Answers
Branch? 1.6.1.x
Description? Redundant code causes the default category of a product to be reset, even when it already has a default category and the default is not given in the CSV.
Type? bug fix
Category? BO
BC breaks? no
Deprecations? no
Fixed ticket? http://forge.prestashop.com/browse/PSCSX-8501
How to test? Download the CSV from the ticket, change the product ID, link the columns (product ID, price) and check if the default category doesn't get reset anymore.

@firstred firstred changed the title Prevent default category reset when already defined CSV Import: Prevent default category reset when already defined Oct 11, 2016
@aleeks aleeks added this to the 1.6.1.8 milestone Oct 11, 2016
@maximebiloe maximebiloe changed the title CSV Import: Prevent default category reset when already defined Prevent default category to be reset when already defined during import Oct 12, 2016
@maximebiloe
Copy link
Contributor

Thanks @firstred!

The fix has already been applied on develop, no need to be cherry-picked.

@maximebiloe maximebiloe merged commit c3a3c91 into PrestaShop:1.6.1.x Oct 12, 2016
@7starsone
Copy link

7starsone commented Dec 3, 2016

Please, there is something you should do on
controllers/admin/AdminImportController.php

  1. Option: let the user download the images directly from the supplier product list,
    so don't force the user to own the images on local server....
    eg.
$imageUrl = //get the image url from the csv settings;
$filename = basename($imageUrl);
 exec("cd $finalDir && wget -c --quiet --retry-connrefused --waitretry=1 -U 'Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0' $imageUrl");

                $url = "http://domain.com/download/img/tmp/{$filename}";
                $handle = curl_init($url);
                curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);

                /* Get the HTML or whatever is linked in $url. */
                $response = curl_exec($handle);

                /* Check for 404 (file not found). */
                $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
                if($httpCode != 200) {
                    echo "Image $filename not found \n";
                    continue;
                } else {
                   $images[] = "http://domain.com/download/img/tmp/{$filename}";

                }

                curl_close($handle);

//then use the array to manage the by now local images and put them in place as usual... this is just an example, you can do it better with ps variables and so on...
  1. When product features are inserted into csv, you ignore the language and update the database for any language... you should find a method to avoid this behavior for multilang installations:
    https://www.prestashop.com/forums/topic/514005-csv-import-features-are-imported-for-any-lang-it-ignores-the-import-language

  2. let the user choose if wants to execute the import by chunks for long product list (eg. do you want to split the file and run the import one at a time? how many files? how much delay among the imports? and so on...)

  3. an interface to automate this method, without need for any external module
    4a) save the csv settings/fields association
    4b) cron download the .csv from url
    4c) do the process... (add new products only? modify only?...)

@gadnis
Copy link

gadnis commented Oct 9, 2017

Hi, I had to find something similar to your code, but it is different. My version 1.6.1.17

Line 1436
$product->id_category_default = isset($product->id_category[0]) ? (int)$product->id_category[0] : '';

I comment it out and now default category is not changing to home.

@xBorderie
Copy link
Contributor

@gadnis I'm not sure I understand what you mean. The code change from this purr-request is already available in 1.6.1.17: https://github.com/PrestaShop/PrestaShop/blob/1.6.1.17/controllers/admin/AdminImportController.php#L1541
What are you trying to achieve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants