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

Allow product import to change previous id_category_default when you force ID #10930

Merged
merged 1 commit into from Oct 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions controllers/admin/AdminImportController.php
Expand Up @@ -1878,12 +1878,11 @@ protected function productImportOne($info, $default_language_id, $id_lang, $forc
$product->id_category = array_values(array_unique($product->id_category));
}

// Will update default category if there is none set here. Home if no category at all.
if (!isset($product->id_category_default) || !$product->id_category_default) {
// this if will avoid ereasing default category if category column is not present in the CSV file (or ignored)
if (isset($product->id_category[0])) {
$product->id_category_default = (int) $product->id_category[0];
} else {
// Category default now takes the value of the first new category during import
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;
}
Expand Down