usermar Posted May 2, 2022 Share Posted May 2, 2022 Hi. I notice that when I create a new category it is not displayed correctly in the public part, it appears without breadcrumbs and without an apparent parent category. The cause is that the "nleft" and "nright" fields of the ps_category table always appear with value 0 and do not have a correct node value. All other fields such as the parent category etc are correct. I have done all kinds of tests but I can't figure out why the nodes are not generated. I have tried disabling most modules, switching to the default theme. I have also upgraded to version 1.7.8.5 in a test environment (I currently have 1.7.8.2 in production). I tried to call the Category::regenerateEntireNtree function to regenerate the categories. None of this seems to work. I would be very grateful if someone could help me or give me some hint. I have searched a lot and have not found any solution. Link to comment Share on other sites More sharing options...
Mian Waqas Posted May 11, 2022 Share Posted May 11, 2022 (edited) On 5/2/2022 at 8:54 PM, usermar said: Hi. I notice that when I create a new category it is not displayed correctly in the public part, it appears without breadcrumbs and without an apparent parent category. The cause is that the "nleft" and "nright" fields of the ps_category table always appear with value 0 and do not have a correct node value. All other fields such as the parent category etc are correct. I have done all kinds of tests but I can't figure out why the nodes are not generated. I have tried disabling most modules, switching to the default theme. I have also upgraded to version 1.7.8.5 in a test environment (I currently have 1.7.8.2 in production). I tried to call the Category::regenerateEntireNtree function to regenerate the categories. None of this seems to work. I would be very grateful if someone could help me or give me some hint. I have searched a lot and have not found any solution. Hi, i am really sorry for the issue you are facing, but Please can you share some screenshots of front office & backoffice category part? your question seems to be very confusy or not related to what you are talking about, that is why there is no reply since 10 days. Regards Edited May 11, 2022 by SMTmardan (see edit history) Link to comment Share on other sites More sharing options...
usermar Posted May 18, 2022 Author Share Posted May 18, 2022 Thank you very much for your reply, sorry for the delay. I will try to explain the problem in a simpler and clearer way. In the ps_category table of the BBDD each category has a value "nleft" and "nright". This value is auto-calculated every time any category or subcategory is added, removed or moved (I don't know exactly how the calculation is done). Apparently, Prestashop uses these values to position the category within the tree of categories and subcategories. My problem is that no matter what I do, since some time ago, any operation with categories gives as value nleft=0 and nright=0. This generates errors and problems in the Front Office part, for example in breadcrumbs or SEO. Any help to find out the cause would be welcome, it's very frustrating. Link to comment Share on other sites More sharing options...
Mian Waqas Posted May 18, 2022 Share Posted May 18, 2022 Hi, Did you tried these suggestions? In Back office, I believe add/delete a category or (temporarily) move a category under a new parent and then save it will rebuild the tree structure. (maybe make a category 'tempcat' and put it under any parent. Then save the category. Check if the left and right values are added in the database. Then delete the tempcat afterwards) Link to comment Share on other sites More sharing options...
usermar Posted May 18, 2022 Author Share Posted May 18, 2022 Thank you very much for your reply, Yes, I have tried everything. Every new category I create has "0" values and if I move this category it still has "0"values. But not only that, whatever I do it doesn't change the values of the rest of the categories. Even if I delete this or another category all the values of the others categories never change. Link to comment Share on other sites More sharing options...
Mian Waqas Posted May 18, 2022 Share Posted May 18, 2022 A question, had you migrated the data from another store? Also when you enable debug mode, and try to create, or move a acategory , are there any errors showing? Regards Link to comment Share on other sites More sharing options...
thisisfine Posted June 3, 2022 Share Posted June 3, 2022 On 5/2/2022 at 5:54 PM, usermar said: the "nleft" and "nright" fields of the ps_category table always appear with value 0 and do not have a correct node value. I am struggling with the same problem. After adding categories from the dash, I have to change manually in the database the values of "nleft" and "nright" fields. Has anyone dealt with this problem? PS v 1.6.1.0 1 Link to comment Share on other sites More sharing options...
musicmaster Posted June 3, 2022 Share Posted June 3, 2022 The most logical explanation is that there is somewhere a php error that stops the code before it can set nleft/nright. But as most of the action happens in ajax calls it is quite hard to find out. Looking in the error log of the server is often the easiest way. Prestools has a function to restore the nleft/nright tree (it is in the Integrity Checks). 1 Link to comment Share on other sites More sharing options...
Yuyuela Posted May 7 Share Posted May 7 I have the same problem. Has anyone found the solution? thank you Link to comment Share on other sites More sharing options...
mudol Posted July 26 Share Posted July 26 (edited) 2024 year i and have this problem too, when adding new category in database are only "0", when i turn on debuge its show: INSERT INTO `ps_category` (`nleft`, `nright`, `level_depth`, `active`, `id_parent`, `id_shop_default`, `is_root_category`, `position`, `date_add`, `date_upd`) VALUES ('0', '0', '3', '1', '4350', '1', '0', '0', '2024-07-26 10:42:04', '2024-07-26 10:42:04') ps 1.6.1.24, updated classes/ controllers, tools/ from prestashop 1.6.1.24 zip from prestashop site. editing or moving category not fix nleft and nright pos 😕 <?php include_once('config/config.inc.php'); include_once('init.php'); Category::regenerateEntireNtree(); ?> in file not working too. EDIT, aaaand fixed! this tool: Prestools help me check where is problem, show many categories that have id_parent = '0', so first use this: UPDATE ps_category SET id_parent = '1' WHERE id_parent = '0'; then must change back root category so in id_category=1 set id_parent to '0', now nleft and right working good, rest of work its to clean all weird categories who have id_parent = '1' thx @musicmaster for tip Edited July 26 by mudol (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted July 26 Share Posted July 26 12 minutes ago, mudol said: 2024 year i and have this problem too, when adding new category in database are only "0", when i turn on debuge its show: INSERT INTO `ps_category` (`nleft`, `nright`, `level_depth`, `active`, `id_parent`, `id_shop_default`, `is_root_category`, `position`, `date_add`, `date_upd`) VALUES ('0', '0', '3', '1', '4350', '1', '0', '0', '2024-07-26 10:42:04', '2024-07-26 10:42:04') ps 1.6.1.24, updated classes/ controllers, tools/ from prestashop 1.6.1.24 zip from prestashop site. editing or moving category not fix nleft and nright pos 😕 <?php include_once('config/config.inc.php'); include_once('init.php'); Category::regenerateEntireNtree(); ?> in file not working too When I look at your SQL command I see an id_parent of 4350. That means that you have (had) at least 4350 categories in this shop. Sounds very weird. Are you sure this id_category exists? Link to comment Share on other sites More sharing options...
mudol Posted July 26 Share Posted July 26 @musicmaster yes, it shop with part to cars ;), but Your prestools help me, thx 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