Jump to content

(SOLVED)EAN Number behind my simplified URL


silki

Recommended Posts

Dear Forum,

i'm working on optimising my simplied URLs. They are working but now there is always the EAN number behind each
link and i have no idea why. I deleted the URL simplified on the databse because i wanted to improve it.
But now i have this problem.

Any ideas?

Thanks

Silki

Link to comment
Share on other sites

So you want to remove the EAN13 from the friendly URL? To do that, change lines 53-56 of classes/Link.php from:

if (is_object($id_product))
   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).'-'.$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__.$lang_link.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :



to:

if (is_object($id_product))
   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).'-'.$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__.$lang_link.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$alias/*.($ean13 ? '-'.$ean13 : '')*/.'.html') :

  • Like 1
Link to comment
Share on other sites

So you want to remove the EAN13 from the friendly URL? To do that, change lines 53-56 of classes/Link.php from:

if (is_object($id_product))
   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).'-'.$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__.$lang_link.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :



to:

if (is_object($id_product))
   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).'-'.$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__.$lang_link.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$alias/*.($ean13 ? '-'.$ean13 : '')*/.'.html') :



Dont kow if its similar to my problem, but i actually want it to show the EAN13 number at the end of the link, i generate the google base feed and links show up without the EAN13 at the end? Looked everywhere, sorry for asking here, hope i can atleast get directed to the proper place.
Link to comment
Share on other sites

Interesting - this seems to have no effect for me.

This is the code in the original Link.php:

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__.$lang_link.(($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__.$lang_link.(($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));
       else
           return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product);
   }



And this is what I changed it to:

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__.(($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));
       else
           return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.intval($id_product);
   }



I've gone over it several times in WinMerge and can't seem to figure out what I'm missing, and why, if I'm missing something, the site wouldn't be broken...

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...
for me not working ... after comment ean13 code , in navigation bar in browser rest : www.mysite.com/categorie/product-123456789.html... need make more modification ? .hteacces file ?
use 1.3.1.1

Did you cleared browser chache and also complie cache at /tools/smarty/compile ?
Link to comment
Share on other sites

  • 2 months later...

Hi Rocky - I've tried commenting out in Link.php in v1.4.1 and then placing Link.php in overrides/classes - I then get a totally blank page :-( Have I missed something in the commenting out somewhere? Thanks, Baz

public function getProductDeletePictureLink($product, $id_picture){
       if (is_object($product))
           return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink().((isset($product->category) AND !empty($product->category) AND $product->category != 'home') ? $product->category.'/' : '').(int)$product->id.'-'.$product->link_rewrite/*.($product->ean13 ? '-'.$product->ean13 : '')*/.'.html?deletePicture='.$id_picture) :
           (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$product->id).'&deletePicture='.$id_picture;
       else
           return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$product.'&deletePicture='.$id_picture;
   }

   /**
     * Return the correct link for product/category/supplier/manufacturer
     *
     * @param mixed $id_OBJ 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)
   {
       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;

Link to comment
Share on other sites

  • 10 months later...

So you want to remove the EAN13 from the friendly URL? To do that, change lines 53-56 of classes/Link.php from:

 

if (is_object($id_product))
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).'-'.$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__.$lang_link.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :

 

to:

 

if (is_object($id_product))
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).'-'.$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__.$lang_link.(($category AND $category != 'home') ? ($category.'/') : '').intval($id_product).'-'.$alias/*.($ean13 ? '-'.$ean13 : '')*/.'.html') :

 

Is there any way to work for PS 1.4.7.0(2) ????????

Link to comment
Share on other sites

Hi Rocky - I've tried commenting out in Link.php in v1.4.1 and then placing Link.php in overrides/classes - I then get a totally blank page :-( Have I missed something in the commenting out somewhere? Thanks, Baz

 

public function getProductDeletePictureLink($product, $id_picture){
	if (is_object($product))
		return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink().((isset($product->category) AND !empty($product->category) AND $product->category != 'home') ? $product->category.'/' : '').(int)$product->id.'-'.$product->link_rewrite/*.($product->ean13 ? '-'.$product->ean13 : '')*/.'.html?deletePicture='.$id_picture) :
		(_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$product->id).'&deletePicture='.$id_picture;
	else
		return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$product.'&deletePicture='.$id_picture;
}

/**
  * Return the correct link for product/category/supplier/manufacturer
  *
  * @param mixed $id_OBJ 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)
{
	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;

Same here ... a white page in PS 1.4.7.0

Link to comment
Share on other sites

  • 2 months later...

For the more recent version (I am on 1.4.4), you just need to apply the same logic to all the mention of EAN in the classes/Link.php file.

 

I found 3 lines in total: Line 53, 69 & 72 in the Link.php file.

 

Then you just need to comment out the part about EAN13. For this, just have a look at what Rocky did above.

Link to comment
Share on other sites

please I have 1.4.8.2 I tried to modify that file, but I do wrong some code, if I use file modified by me it doesn't work (500 error), please could you give to me file right for that version of ps?

Thanks

Link to comment
Share on other sites

Here are the changes on the file classes/Link.php

 

Line 53

return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink().((isset($product->category) AND !empty($product->category) AND $product->category != 'home') ? $product->category.'/' : '').(int)$product->id.'-'.$product->link_rewrite/*.($product->ean13 ? '-'.$product->ean13 : '')*/.'.html?deletePicture='.$id_picture) :

 

Line 69

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') :

 

Line 72

 

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') :

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