Ecigarlife Posted April 2, 2019 Share Posted April 2, 2019 Members 2 75 posts Posted 11 hours ago Hi, I Activated the multistore one month ago, but when i Create a category, the values of the fieds NLEFT and NRIGHT in the ps_category table is 0 always. I Execute manually "Category::regenerateEntireNtree();" but it doent do anything. Maybe is because my root category is "2"? This is my Code public static function regenerateEntireNtree() { $id = Context::getContext()->shop->id; $id_shop = $id ? $id: Configuration::get('PS_SHOP_DEFAULT'); $categories = Db::getInstance()->executeS(' SELECT c.`id_category`, c.`id_parent` FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.') ORDER BY c.`id_parent`, cs.`position` ASC'); $categories_array = array(); foreach ($categories as $category) $categories_array[$category['id_parent']]['subcategories'][] = $category['id_category']; $n = 1; if (isset($categories_array[0]) && $categories_array[0]['subcategories']) Category::_subTree($categories_array, $categories_array[0]['subcategories'][0], $n); } protected static function _subTree(&$categories, $id_category, &$n) { $left = $n++; if (isset($categories[(int)$id_category]['subcategories'])) foreach ($categories[(int)$id_category]['subcategories'] as $id_subcategory) Category::_subTree($categories, (int)$id_subcategory, $n); $right = (int)$n++; Db::getInstance()->execute(' UPDATE '._DB_PREFIX_.'category SET nleft = '.(int)$left.', nright = '.(int)$right.' WHERE id_category = '.(int)$id_category.' LIMIT 1'); } Any help please? thank you very much Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now