Jump to content

rebuild / regenerate category tree


Recommended Posts

nleft and nright values for new categories are 0 . They are not getting updated.

the new categories that i create are not visible in the front office

in the screenshit you will be able to see the last 4 categories have 0 nleft and nright values

.htaccess file has not been changes

images for other categories not visible in top horizontal menu

rest all categories work fine

these new categories are set to be enabled obviously

i want to regenerate the category tree---prestashop is not doing it automatically for me

 

 

post-1102264-0-78742300-1443759511_thumb.jpg

 

 

 

Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...
  • 8 months later...

Hi all,

 

 

I use this : 

Db::getInstance()->execute('UPDATE `ps_category` SET `nleft`=0,`nright`=0 WHERE 1');
Category::regenerateEntireNtree();

 

Now each nleft and Nrights are on 0. But the catagory regeneration does not work.
I try to use the Regenerate Category Tree module. When I regenerate, it does not work too.

 

Maybe a problem in my pq_category table?
Can someone help me?

 

Thanks,

Kev

Link to comment
Share on other sites

  • 3 years later...

Hi everyone,

 

I need to regenerate the category tree of my prestashop 1.7.5.1.0. I don't know where to apply any of this solutions :

Db::getInstance()->execute('UPDATE `ps_category` SET `nleft`=0,`nright`=0 WHERE 1'); Category::regenerateEntireNtree();

or

Category::regenerateEntireNtree();

Can someone could be more specific or share an example of modifiefd file in order for me to understand please ? And is it still working for prestashop 1.7.5.1.0 ?

I've tried to load the category tree module https://github.com/johnulist/category-tree-regenerator

and it's not working.

Best regards,

Clément

Link to comment
Share on other sites

On 3/15/2021 at 11:03 AM, Blue Bear said:

Hi everyone,

 

I need to regenerate the category tree of my prestashop 1.7.5.1.0. I don't know where to apply any of this solutions :

Db::getInstance()->execute('UPDATE `ps_category` SET `nleft`=0,`nright`=0 WHERE 1'); Category::regenerateEntireNtree();

or

Category::regenerateEntireNtree();

Can someone could be more specific or share an example of modifiefd file in order for me to understand please ? And is it still working for prestashop 1.7.5.1.0 ?

I've tried to load the category tree module https://github.com/johnulist/category-tree-regenerator

and it's not working.

Best regards,

Clément

I have no idea why nleft and nright are set to zero first. Seems just foolish to me.

Note that when you regenerate it recreates the tree from the information it finds in id_parent, is_root, position and level. So when there is a problem with those values regeneration won't work.

Prestools has some kind of regeneration function too in its Integrity Checks.

Link to comment
Share on other sites

  • 1 year later...
On 3/18/2021 at 7:43 PM, musicmaster said:

I have no idea why nleft and nright are set to zero first. Seems just foolish to me.

Because if a category is orphaned, it will not be modified by regenerateEntireNtree() and will keep his nright and nleft which will be in conflict with good ones.

Link to comment
Share on other sites

  • 8 months later...

The problem I had was that I needed to be logged to be able to run the function. Here is my file that I can fire even if I'm not logged in the admin

 

Echo "Whatever pleases you to print on the page when it is done";

//Indicate where to find you config file
require 'Your_Path_To_This_File/config/config.inc.php';

//Set all nleft and nright to zero prior to generate
Db::getInstance()->execute('UPDATE `ps_category` SET `nleft`=0,`nright`=0 WHERE 1');
//Then regenerate
Category::regenerateEntireNtree();

 

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...