vincentdenkspel Posted October 28, 2011 Share Posted October 28, 2011 Hi all, For some products I've entered the ean13 numbers. The numbers are now visible in the url, for example: http://denkspellenpa...4301515296.html Does anybody have an idea what can be done so that the ean13 number is not visible in the url ? Thank you for your reply. Best regards, Vincent Link to comment Share on other sites More sharing options...
phrasespot Posted November 1, 2011 Share Posted November 1, 2011 This is not the most elegant way to do it, though the shortest. Locate the file /classes/Link.php, find the method getProductLink and change public function getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL, $id_lang = NULL) { if (is_object($id_product)) return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).((isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home') ? $id_product->category.'/' : '').(int)$id_product->id.'-'.$id_product->link_rewrite.($id_product->ean13 ? '-'.$id_product->ean13 : '').'.html') : (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product->id); elseif ($alias) return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).(($category AND $category != 'home') ? ($category.'/') : '').(int)$id_product.'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') : (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product); else return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product; } to public function getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL, $id_lang = NULL) { if (is_object($id_product)) return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).((isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home') ? $id_product->category.'/' : '').(int)$id_product->id.'-'.$id_product->link_rewrite.($id_product->ean13 ? '' : '').'.html') : (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product->id); elseif ($alias) return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).(($category AND $category != 'home') ? ($category.'/') : '').(int)$id_product.'-'.$alias.($ean13 ? '' : '').'.html') : (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product); else return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product; } and here is a summary of changes, in case you're using a different version. - return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).((isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home') ? $id_product->category.'/' : '').(int)$id_product->id.'-'.$id_product->link_rewrite.($id_product->ean13 ? '-'.$id_product->ean13 : '').'.html') : + return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).((isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home') ? $id_product->category.'/' : '').(int)$id_product->id.'-'.$id_product->link_rewrite.($id_product->ean13 ? '' : '').'.html') : - return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).(($category AND $category != 'home') ? ($category.'/') : '').(int)$id_product.'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') : + return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).(($category AND $category != 'home') ? ($category.'/') : '').(int)$id_product.'-'.$alias.($ean13 ? '' : '').'.html') : Link to comment Share on other sites More sharing options...
vincentdenkspel Posted November 16, 2011 Author Share Posted November 16, 2011 Hi Prasespot, Thank you for your reply and sorry for my late reply. I was under the impression that I would receive a notification but I didn't. So once again sorry for my late reply. I will make the changes. Once again thanks Link to comment Share on other sites More sharing options...
ukbaz Posted February 3, 2012 Share Posted February 3, 2012 Hi - the code is different in v1.4.6.2. How do I get rid of EAN13 in that version? thanks, Baz Link to comment Share on other sites More sharing options...
aaron87 Posted March 6, 2012 Share Posted March 6, 2012 Yes, apparently, the code has changed If someone has the code to replace for prestashop 1.4.6, that would be great. Thanx Link to comment Share on other sites More sharing options...
IlieMafiotu Posted September 6, 2012 Share Posted September 6, 2012 Hi, this is what i did: You have to create an override class for friendly url build. This is done in classes/Link.php For ugrade reasons you can not edit this file. You have to create an override for this file, this is how: 0. If you dont understand this, ask somebody to do it for you 1. Always backup your files !!!! 2. Create a folder /override in root directory on shop, if not already exists 3. create a file called Link.php this is the override file for classes/Link.php 4. copy the following code into it <?php class Link extends LinkCore{ /** * Return the correct link for product/category/supplier/manufacturer * * @param mixed $id_product Can be either the object or the ID only * @param string $alias Friendly URL (only if $id_OBJ is the object) * @return string link */ public function getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL, $id_lang = NULL) { global $cookie; if (is_object($id_product)) { $link = ''; if ($this->allow == 1) { $link .= (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang)); if (isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home') $link .= $id_product->category.'/'; else $link .= ''; $link .= (int)$id_product->id.'-'; if (is_array($id_product->link_rewrite)) $link.= $id_product->link_rewrite[(int)$cookie->id_lang]; else $link.= $id_product->link_rewrite; if ($id_product->ean13) $link .= ''; //$link .='-'.$id_product->ean13; else $link .= ''; $link .= '.html'; } else { $link .= (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product->id); } //die($link); return $link; } else if ($alias) { $link = ''; if ($this->allow == 1) { $link .= (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang)); if ($category AND $category != 'home') $link .= $category.'/'; else $link .= ''; $link .= (int)$id_product.'-'.$alias; if ($ean13) $link .= ''; //$link .='-'.$ean13; else $link .= ''; $link .= '.html'; } else $link .=(_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product); return $link; } else return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product; } } the lines changed are, 2 in total $link .= ''; //$link .='-'.$ean13; in this way it does not append the ean13 filed to the link Hope i wrote it undersatndeble and that it hepls others. Best regards, Zoli. 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