sumitt2004 Posted January 29, 2013 Share Posted January 29, 2013 Hi, I am facing a strange issue with PS 1.5.3.1, when I installed PS then I choose demo products with computer theme. By default there were 3 categories Laptop, iPod and Accessories I deleted 2 categories (except Laptop) and added few more. Now only one (Laptop) link is working all new added categories links are going to 404. I tried below steps: 1. Checked all categories are Enabled. 2. All new categories are linked with Home. 3. In category controller I check code which is redirecting the link and found that !$this->category->inShop() is returning true. in below code. public function canonicalRedirection($canonicalURL = '') { if (!Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop()) { $this->redirect_after = '404'; $this->redirect(); } if (!Tools::getValue('noredirect') && Validate::isLoadedObject($this->category)) parent::canonicalRedirection($this->context->link->getCategoryLink($this->category)); } Could anybody please help me get rid from this? Link to comment Share on other sites More sharing options...
sumitt2004 Posted January 31, 2013 Author Share Posted January 31, 2013 Is there anyone who can please help me on this? Link to comment Share on other sites More sharing options...
digitalis Posted March 5, 2013 Share Posted March 5, 2013 (edited) Hi, I am facing the exact same problem. The only thing different from sumitt2004 is that I have imported about 1000 products via CSV from an old setup of Prestashop (1.3.x). public function canonicalRedirection($canonicalURL = '') { var_dump(Validate::isLoadedObject($this->category)); // true var_dump($this->category->inShop()); // false var_dump($this->category->isAssociatedToShop()); // true if (!Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop()) { echo "it's coming here"; exit; $this->redirect_after = '404'; $this->redirect(); } if (!Tools::getValue('noredirect') && Validate::isLoadedObject($this->category)) parent::canonicalRedirection($this->context->link->getCategoryLink($this->category)); } Everything works fine-ish in the BO. Edited March 5, 2013 by digitalis (see edit history) Link to comment Share on other sites More sharing options...
digitalis Posted March 5, 2013 Share Posted March 5, 2013 This might help.. It turns out that it doesn't go 404 if I try to list the products listed under the 'home' category. http://www.XXXXXX.com/index.php?id_category=2&controller=category All the other categories in the system (even 1 'Root') go 404. Am I doing anything wrong? Thanks in advance. Link to comment Share on other sites More sharing options...
digitalis Posted March 5, 2013 Share Posted March 5, 2013 Mmm... I fixed it. I don't know if this quick-hack is safe though. In Category class: public function inShop(Shop $shop = null) { if (!$shop) $shop = Context::getContext()->shop; if (!$interval = Category::getInterval($shop->getCategory())) return false; return ($this->nleft >= $interval['nleft'] && $this->nright <= $interval['nright']); } It turns out that the value nright from the home category wasn't big enough after the import and I just changed it to 200. Does it make sense? 1 Link to comment Share on other sites More sharing options...
digitalis Posted March 5, 2013 Share Posted March 5, 2013 (edited) I guess I won't have problems with this solution since I only run one shop. If someone reads this and is interested the multishop feature don't try what I just said in the post above and wait until someone more experienced gives a more adequate solution. Edited March 5, 2013 by digitalis (see edit history) 1 Link to comment Share on other sites More sharing options...
bteo Posted March 10, 2013 Share Posted March 10, 2013 Digitalis, Your fix did work for me too I was looking for so long for a fix couldn't find it. I've got 3000+ products in the database so I hope this won't cause any issues with loading times. Anyways why did you pick 200? If I intend to have 5000+ products in the database would 200 still be alright to use in your opinion? Link to comment Share on other sites More sharing options...
digitalis Posted March 11, 2013 Share Posted March 11, 2013 Hi Bteo, I picked 200 since this shop I am working on has about 150~ categories, so AFAIK it doesn't have much to do with the amount of products your store has but the number of categories. Then again, I am really newbie to PrestaShop. I'd wait and see if someone more experienced with PS can help with this issue. Link to comment Share on other sites More sharing options...
tomerg3 Posted March 11, 2013 Share Posted March 11, 2013 Did you try to turn off the cache option in Advanced Preferences->Performance. Category links are being cached, and will not update if the cache is active. Link to comment Share on other sites More sharing options...
digitalis Posted March 11, 2013 Share Posted March 11, 2013 Did you try to turn off the cache option in Advanced Preferences->Performance. Yes, I did. That didn't seem to be the problem at least in my case. Link to comment Share on other sites More sharing options...
bteo Posted March 11, 2013 Share Posted March 11, 2013 I've got 400 categories but still worked for me. Also its not a cache problem. I believe the problem is the importing via csv. Could be a bug with prestashop. When importing via csv I noticed in mysql under the Products section the nleft & nright fields are 0 Every other category / sub category in the database has numbers in this field except the ones I've imported via csv. Link to comment Share on other sites More sharing options...
bteo Posted March 11, 2013 Share Posted March 11, 2013 Ok found the fix its in Lopcalization > Countries > EDIT COUNTRY You can change the display order of address, state, etc... Link to comment Share on other sites More sharing options...
paperpast Posted July 9, 2013 Share Posted July 9, 2013 (edited) I added one new fake category, made home the root directory, saved, and now every other category links to the correct products. It also made the downward arrow appear near the Category title like it should be. Edited July 9, 2013 by paperpast (see edit history) 1 Link to comment Share on other sites More sharing options...
MassiveRC Posted July 9, 2013 Share Posted July 9, 2013 I get this damn bug any time I have to take an order from a customer over the phone from a different country. I have to log out as that customer and I think reselect English as my localization and maybe force template recompile.........I'm not sure, but there's a magical process that I'll make note of next time it happens, but I mostly wildly click on crap in a mad rush to stop losing freaking orders for a whole damn day. I'd actually pay good money for this software if I could get guarantees it wouldn't blow up from the slightest sneeze. Link to comment Share on other sites More sharing options...
ivanomino Posted February 3, 2014 Share Posted February 3, 2014 Hi to everybody, i have the same issue on my website www.iloveisicily.ie - Products and category are in the database, but on the categories link i get a 404 error. Also, Prestashop system doesn't show this categories in Breadcrumb, if i use the istant search. This matter is born with the ultimate upgrade to new version Link to comment Share on other sites More sharing options...
monika.canoneye Posted November 14, 2014 Share Posted November 14, 2014 I am also getting problem earlier all is well now whenever i add any any sub categoery it is howing in the backend but in the FO when i click on the sub category it redirects to 404 page Link to comment Share on other sites More sharing options...
haunter Posted January 5, 2016 Share Posted January 5, 2016 Just call anywhere Category::regenerateEntireNtree() Link to comment Share on other sites More sharing options...
ruisonika Posted May 8, 2017 Share Posted May 8, 2017 Mmm... I fixed it. I don't know if this quick-hack is safe though. In Category class: public function inShop(Shop $shop = null) { if (!$shop) $shop = Context::getContext()->shop; if (!$interval = Category::getInterval($shop->getCategory())) return false; return ($this->nleft >= $interval['nleft'] && $this->nright <= $interval['nright']); } It turns out that the value nright from the home category wasn't big enough after the import and I just changed it to 200. Does it make sense? Sorry i dont understand what you mean with i just changed it to 200???? Where is it on the code you post it the value? Or is there a specific place to do that? Thanks Link to comment Share on other sites More sharing options...
jrgrafisk Posted September 13, 2017 Share Posted September 13, 2017 For me, the .htaccess needed regeneration. Did it via https://www.templatemonster.com/help/prestashop-1-6-x-how-to-regenerate-htaccess-file.html Link to comment Share on other sites More sharing options...
TempFail Posted October 8, 2017 Share Posted October 8, 2017 Just call anywhere Category::regenerateEntireNtree() How? I have also 404 categories after csv import. Htaccess regeneration didn't helped. Link to comment Share on other sites More sharing options...
Recommended Posts