Jump to content

Edit History

Paul C

Paul C


typos

This is all due to an upgrade in the past possibly not working properly or the issue being forgotten in later updates (it started around 2014 if I remember correctly)....

In stores that were installed before multi-shop was a thing the "Home" category was category 1. When multi-shop was introduced there was a need to have a "Home" category potentially for each shop (although multiple shops could have the same category tree and therefor the same "Home" I guess).

So.... after multi-shop was introduced category 1 now became "Root" and category 2 was "Home" with a parent_id of 1 (and confusingly the field is_root_category is set to 1 for the "Home" categories but not for the "Root" category).

If your install pre-dates multi-shop, then category 1  should have is_root_category = 1  and is "Home", plus it will have a parent_id which points to the "Root" category added when the catalog was upgraded for multi-shop (e.g. 132). That "Root" category (132 in this example) should have a parent_id of 0, is_root_category = 0 and active = 1. If you don't use multi-shop then you should only have ONE category with is_root_category = 1 (almost certainly this will be category 1). If you DO use multi-shop, then you may have more than one.

Due to the structure of the category tree you may have to rebuild the tree if you manually change entries in the database. So for my example you can do this whole thing using:

// Set 'home' category as the root category
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `is_root_category` = 1 WHERE `id_category` = 1';
$result = Db::getInstance()->Execute($query);

// Set the parent of the home category active and then set its parent to 0 (queries split for clarity)
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `active` = 1 WHERE `id_category` = 132';
$result = Db::getInstance()->Execute($query);
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `id_parent` = 0 WHERE `id_category` = 132';
$result = Db::getInstance()->Execute($query);

// Rebuild the entire category tree
Category::regenerateEntireNtree();

 

Paul C

Paul C

This is all due to an upgrade in the past possibly not working properly or the issue being forgotten in later updates (it started around 2014 if I remember correctly)....

In stores that were installed before multi-shop was a thing the "Home" category was category 1. When multi-shop was introduced there was a need to have a "Home" category potentially for each shop (although multiple shops could have the same category tree and therefor the same "Home" I guess).

So.... after multi-shop was introduced category 1 now became "Root" and category 2 was "Home" with a parent_id of 1 (and confusingly the field is_root_category is set to 1 for the "Home" categories but not for the "Root" category).

If your install pre-dates multi-shop, then category 1  should have is_root_category = 1  and is "Home", plus it will have a parent_id which points to the "Root" category added when the catalog was upgraded for multi-shop (e.g. 132). That Root category (132 in this example) should have a parent_id of 0, is_root_category = 0 and active = 1. If you don't use multi-shop then you should only have ONE category with is_root_category = 1 (almost certainly this will be category 1). If you DO use multi-shop, then you may have more than one.

Due to the structure of the category tree you may have to rebuild the tree if you manually change entries in the database. So for my example you can do this whole things using:

// Set 'home' category as the root category
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `is_root_category` = 1 WHERE `id_category` = 1';
$result = Db::getInstance()->Execute($query);

// Set the parent of the home category active and then set its parent to 0 (queries split for clarity)
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `active` = 1 WHERE `id_category` = 132';
$result = Db::getInstance()->Execute($query);
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `id_parent` = 0 WHERE `id_category` = 132';
$result = Db::getInstance()->Execute($query);

// Rebuild the entire category tree
Category::regenerateEntireNtree();

 

Paul C

Paul C

This is all due to an upgrade in the past possibly not working properly or the issue being forgotten in later updates (it started around 2014 if I remember correctly)....

In stores that were installed before multi-shop was a thing the "Home" category was category 1. When multi-shop was introduced there was a need to have a "Home" category potentially for each shop (although multiple shops could have the same categories and therefor same "Home" I guess).

So.... after multi-shop was introduced category 1 now became "Root" and category 2 was "Home" with a parent_id of 1 (and confusingly the field is_root_category is set to 1 for the "Home" categories but not for the "Root" categories).

If your install pre-dates multi-shop, then category 1  should have is_root_category = 1  and is your "Home", plus it will have a parent_id which is the "Root" category added when the catalog was upgraded for multi-shop (e.g. 132). That Root category (132 in this example) should have a parent_id of 0, is_root_category = 0 and active = 1. If you don't use multi-shop then you should only have ONE category with is_root_category = 1 (almost certainly this will be category 1). If you DO use multi-shop, then you may have more than one.

Due to the structure of the category tree you may have to rebuild the tree if you manually change entries in the database. So for my example you can do this whole things using:

// Set 'home' category as the root category
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `is_root_category` = 1 WHERE `id_category` = 1';
$result = Db::getInstance()->Execute($query);

// Set the parent of the home category active and then set its parent to 0 (queries split for clarity)
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `active` = 1 WHERE `id_category` = 132';
$result = Db::getInstance()->Execute($query);
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `id_parent` = 0 WHERE `id_category` = 132';
$result = Db::getInstance()->Execute($query);

// Rebuild the entire category tree
Category::regenerateEntireNtree();

 

×
×
  • Create New...