Jump to content

PS 1.6.1 Nelf & Nright 0 Multistore


Recommended Posts

  • Ecigarlife
  • Members
  • 2
  • 75 posts


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++;

                       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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...