From 4d68595447e2e118517240d8057c24e1a859d5d6 Mon Sep 17 00:00:00 2001 From: sjousse Date: Wed, 4 Sep 2013 18:26:24 +0200 Subject: [PATCH] ShopImporter module is now aware of multi-shop Imported categories was affected to Root category instead of a Shop's Home category. I took the first shop home category is by default. Maybe adding an option to choose the shop where the datas should be imported. --- modules/shopimporter/shopimporter.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/shopimporter/shopimporter.php b/modules/shopimporter/shopimporter.php index 1383d09da..ac969543a 100644 --- a/modules/shopimporter/shopimporter.php +++ b/modules/shopimporter/shopimporter.php @@ -959,7 +959,17 @@ class shopimporter extends ImportModule c.id_parent = c2.`id_category_'.bqSQL($moduleName).'` SET c.id_parent = c2.id_category - WHERE c.`id_category_'.bqSQL($moduleName).'` != 0'); + WHERE c.`id_category_'.bqSQL($moduleName).'` != 0 + AND c.`id_parent` != 0'); + + // get first PS home category's id + $home_categories = Category::getRootCategories(); + $home_category_id = $home_categories[0]['id_category']; + Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'category c + SET c.id_parent = '.$home_category_id.' + WHERE c.`id_category_'.bqSQL($moduleName).'` != 0 + AND c.`id_parent` = 0'); + $category = new Category(); $cats = $category->getSimpleCategories((int)Configuration::get('PS_LANG_DEFAULT')); foreach($cats as $cat)