diana13 Posted October 8, 2009 Share Posted October 8, 2009 At some point, my products url looks like:www.mysite.com/idproduct-product-name.htmlBut now, all my products links are:www.mysite.com/category/idproduct-product-name.htmlWithout any changes in htaccessHow can I remove category from product link? I want them to show like in the first link. Link to comment Share on other sites More sharing options...
kratzbaum Posted December 19, 2009 Share Posted December 19, 2009 I'm also interested in this problem.I'm upgarding from a lower version of prestashop and would like to kee urls intact.Help appreciated. Link to comment Share on other sites More sharing options...
diana13 Posted December 19, 2009 Author Share Posted December 19, 2009 You have to modify classes/Link.php. Find the function "public function getProductLink" (line 37)and replace the entire function (lines 37 to 48) with public function getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL) { if (!isset($this->allow)) $this->allow = 0; if (is_object($id_product)) return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.intval($id_product->id).'-'.$id_product->link_rewrite.($id_product->ean13 ? '-'.$id_product->ean13 : '').'.html') : (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product->id)); elseif ($alias) return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.intval($id_product).'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') : (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product)); else return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product); } Link to comment Share on other sites More sharing options...
kratzbaum Posted December 20, 2009 Share Posted December 20, 2009 Thanks a lot. I will check your solution later today.I was already looking at this piece of code earlier but couldn't get my head around it. Link to comment Share on other sites More sharing options...
diana13 Posted December 20, 2009 Author Share Posted December 20, 2009 I'm glad I could help you.Can you tell me what module do you use for product comment? I like it. Link to comment Share on other sites More sharing options...
kratzbaum Posted December 21, 2009 Share Posted December 21, 2009 The commenting function is not a module for prestashop. It's a custom solution based on javascript, ruby on rails, an json. It's running on a different server. I have programmed it myself to suit my specific needs. Link to comment Share on other sites More sharing options...
idseo Posted June 29, 2011 Share Posted June 29, 2011 Thank You so much search for this for long time Link to comment Share on other sites More sharing options...
antonpas_bcn Posted July 12, 2012 Share Posted July 12, 2012 (edited) ---Delete please--- Edited July 12, 2012 by antonpas_bcn (see edit history) Link to comment Share on other sites More sharing options...
mike_davidson Posted July 12, 2012 Share Posted July 12, 2012 You can revert back to the original file and the problem would get solved. Link to comment Share on other sites More sharing options...
davers44 Posted April 16, 2013 Share Posted April 16, 2013 Hi, I see several prestashop folders that do not have category subfolders in their product friendly url, in my PS1.4 seems like category is added to every product URL.I often change subcategory and not having it included into product url will help avoiding 404 errors. I tried to edit only link.php as suggested above removing category from getproductlink function and it seems to work fine in localhost. Is that really all I need to do or I risk errors in the future? Thanks You have to modify classes/Link.php. Find the function "public function getProductLink" (line 37) and replace the entire function (lines 37 to 48) with public function getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL) { if (!isset($this->allow)) $this->allow = 0; if (is_object($id_product)) return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.intval($id_product->id).'-'.$id_product->link_rewrite.($id_product->ean13 ? '-'.$id_product->ean13 : '').'.html') : (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product->id)); elseif ($alias) return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.intval($id_product).'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') : (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product)); else return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product); } Link to comment Share on other sites More sharing options...
Recommended Posts