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

CSV Import Update Issue: Updating a product's category on CSV Import does not set the new category as default [with temporary code solution] #1058

Closed
Acer-ZA opened this issue Sep 16, 2019 · 0 comments

Comments

@Acer-ZA
Copy link
Contributor

Acer-ZA commented Sep 16, 2019

On TB 1.1.0:
Updating a product's category on CSV Import does not set the new category as default.
This affects product breadcrumb display - where it still shows the previous category breadcrumb.
Similar ticket on PS 1.7 forum with a solution - the solution was integrated into PS 1.7

Tickets on PS:
PrestaShop/PrestaShop#10930
PrestaShop/PrestaShop#10930

There is a temporary solution to modify the code in AdminImportController.php, but this will always update the product's category to default. I've been informed that some users may not want this to happen. The user on the PS forum as well as Ninja on the TB forum have suggested a compromise solution where the User can choose if he wants this to happen. Either by a new column on the CSV file or by a new button on the Import screen.

Link to the original issue on the TB forum:

https://forum.thirtybees.com/topic/3478-should-solution-be-integrated-into-tb-solved-please-help-csv-product-import-problem-moving-category-issue-product-breadcrumb-not-updating-default-category-issue/#comment-30590

Ninja's comment:
https://forum.thirtybees.com/topic/3478-should-solution-be-integrated-into-tb-solved-please-help-csv-product-import-problem-moving-category-issue-product-breadcrumb-not-updating-default-category-issue/?do=findComment&comment=30476

Tempory solution or code that sets new category as default on CSV Import:

The code has the following effect:
On CSV Import, the product's category is updated, the product's breadcrumb is updated and the "default category" is updated and reflects in the backend 🙂

How to update:

In AdminImportController.php:
Find: // Will update default category if there is none set here. Home if no category at all.

Change code to:

if (isset($product->id_category[0])) { 
        $product->id_category_default = (int)$product->id_category[0]; 
    } else { 
        if (!isset($product->id_category_default) || !$product->id_category_default) { 
            $defaultProductShop = new Shop($product->id_shop_default); 
            $product->id_category_default = Category::getRootCategory(null, Validate::isLoadedObject($defaultProductShop) ? $defaultProductShop : null)->id; 
        } 
    } 

As this is one of my first issue posts, please point out any issues or improvements that I can make on future issue posts. Thanks :)

@Acer-ZA Acer-ZA changed the title CSV Import Update Issue: Updating a product's category on CSV Import does not set the new category as default. CSV Import Update Issue: Updating a product's category on CSV Import does not set the new category as default [with temporary code solution] Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants