tufany Posted April 10, 2011 Share Posted April 10, 2011 Hi,I want to insert categories from xml file prestashop v1.4.what is the PHP code or formula of ps_category nleft and nright.I can't find how it works nleft and nright formulation. Link to comment Share on other sites More sharing options...
tomerg3 Posted April 10, 2011 Share Posted April 10, 2011 They should get populated automatically, try leaving them as blank.You may have to create the category object for that category id for it to happen. Link to comment Share on other sites More sharing options...
andrex84 Posted April 14, 2011 Share Posted April 14, 2011 Got the same Issue. Database get automatically updated and nothing gets entered into those fields. When you go into phpmyadmin, all nleft and nright are zero. But when you, in the admin panel, add a new category, everything will be updated. Is there a way to update the field automatically? Link to comment Share on other sites More sharing options...
andrex84 Posted April 14, 2011 Share Posted April 14, 2011 Breadcrumbs weren't working and it took me ages to figure out, but thanks to my colleague I found a solution. There's a function in the Class Category called regenerateEntireNtree(). In his script, that automatically fills the prestashop database with items he added the following code to get the database updated again: include(dirname(__FILE__).'/config/config.inc.php'); Category::regenerateEntireNtree(); 3 Link to comment Share on other sites More sharing options...
tufany Posted April 14, 2011 Author Share Posted April 14, 2011 Thanks for your replay,Firstly, i write these codes to my php file. But it didn't regenerate.When i create a new php file only that two rows. it did. Do you have any idea why not work from my php file ( i put this row : include(dirname(__FILE__).'/config/config.inc.php'); top of page and this row bottom. ) .My file not give any mistakes and looks like it done. But when i control the database there are no changes. Link to comment Share on other sites More sharing options...
andrex84 Posted April 15, 2011 Share Posted April 15, 2011 Is your file in the right directory? you can change the include to include('/var/www/prestashopfolder/config/config.inc.php'); // absolute path or include('../shop/config/config.inc.php'); // relative path Link to comment Share on other sites More sharing options...
tufany Posted April 15, 2011 Author Share Posted April 15, 2011 Is your file in the right directory? you can change the include toinclude('/var/www/prestashopfolder/config/config.inc.php'); // absolute path or include('../shop/config/config.inc.php'); // relative path include('../../config/config.inc.php'); Two file i use the same path. if i use regenerate.php ıts ok. But i want to add my categoryadd.php file. Link to comment Share on other sites More sharing options...
Alex Zhukov Posted May 4, 2011 Share Posted May 4, 2011 managing hierarchical data in mySQLhttp://dev.mysql.com/tech-resources/articles/hierarchical-data.html Link to comment Share on other sites More sharing options...
Silvie Posted February 6, 2013 Share Posted February 6, 2013 Alex, your link gives a 404, thanks for a kick that lead me to a workaround, though.. I also experienced issues with categories and redirect loops recently. I am trying to get a multishop to work, which is not easy at all. When I added a new category, it gave me a redirect loop. The other categories created earlier worked fine, which is strange. My PS is v1.5.3 and it was upgraded from 1.3.6. I tried running the method as Andrex84 suggested above, but it didn't work for me. So I went to my database again and I could see that the values in nleft and nright are in a row in the "old" categories, that worked fine. The couples for nleft and nright in my case are always (1, 2), (3, 4), (5, 6), (7, 8) if the categories don't have any subcategories. The workaround that worked for me was that I simply inserted the next couple in the nleft and nright columns, which in my case was (31, 32), (33, 34) and the categories work fine now! I am aware that this can possibly cause issues in the future, but I don't have any other solution right now.. I didn't find any other way how to force the program to rebuild the categories tree so far.. Link to comment Share on other sites More sharing options...
alin001 Posted May 27, 2013 Share Posted May 27, 2013 (edited) managing hierarchical data in mySQL http://dev.mysql.com...hical-data.html new working link: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ Edited May 27, 2013 by alin001 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts