Jump to content

[SOLVED] Add the manufacturer name into the rewritten URL


webroro

Recommended Posts

Hi everyone, i have a little problem with prestashop URL customisation. I've already tried to edit code in link.php but i can't understand the code enough to do it without help.
i'd like to add the manufacturer name (brand) into the URL :

replace :

http://url/category/10-productname.html



with

http://url/category/10-brand-productname.html



Does any of you have any idea how to do that ? It should not require editing the .htaccess file.

Thanks for your help !

Link to comment
Share on other sites

Try changing lines 44-49 of classes/Link.php (in PrestaShop v1.3.1) from:

if (is_object($id_product))
   return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.(($id_product->category != 'home' AND !empty($id_product->category)) ? $id_product->category.'/' : '').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__.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :
   (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product));



to:

if (is_object($id_product))
{
   $manufacturer = new Manufacturer($id_product->id_manufacturer);
   return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$lang_link.(($id_product->category != 'home' AND !empty($id_product->category)) ? $id_product->category.'/' : '').intval($id_product->id).'-'.$manufacturer->link_rewrite.'-'.$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)
{
   $product = new Product($id_product);
   $manufacturer = new Manufacturer($product->id_manufacturer);
   return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$manufacturer->link_rewrite.'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :
   (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product));
}

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