Jump to content

1.5, friendly URLs, many languages and sitemap - Solution? When?


Recommended Posts

Hello PrestaTeam!

 

As the whole community sees things are getting better, there's action in github and your product is on the right way.

 

I'm building mi site for 5-6 months now and I'm on the final stretch - edited the default theme, imported products, updated to 1.5.3.1, the site is working fine with no major FO flaws so I would like to migrate it asap.

 

But there's one thing that stops me - Prestashop's sitemap and it's current condition.

 

Let me describe my configuration:

1. Friendly URLs turned ON on shared hosting runing mod_rewrite in CGI so as we know 'it's working' but the message in BO stays there.

2. I have 2 languages - EN and BG

 

Sitemap issues:

1. When Friendly URLs enabled - product links in the sitemap are not rewritten. If I enter that address in my browser it redirects me to the Frienly URL but would that effect Google's craw rate?

2. Product pages are indexed in the sitemap only with language ID=1 and product pages with Bulgarian link are missing. Why? This is what troubles me most because at the moment I'm selling localy only and I don't want to loose my rankings in Bulgarian serps

3.Picture names are also included only in English - currently it's very good for google to have product images with names - it gives very good results on long keyword searches and drags good amount of users to your shop. When I click on 'save image' in FO it rewrites it for both languages but only English is indexed in the sitemaps. This is very important also.

 

I think there should be more clarity about the sitemap.

I'm posting this here to be seen by more people. If you consider appropriate you can move it under SEO section.

 

Best regards

Edited by the.rampage.rado (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

1. open gsitemap.php

2. go to line 180 and there you'll find the following part of SQL

 

LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (ps.id_category_default = cl.id_category AND pl.id_lang = X AND cl.id_shop = '.(int)$id_shop.')

at the point of bold replace the variable with your lang id

 

3. go to line 208 and find the following line (my proposal include at the end of line something very useful, 3 extras parameters)

 

$tmpLink = $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], X ,null,0,true);

 

at the point of bold replace the X with your lang id.

 

With those modifications you'll have a sitemap.xml with friendly URL's in your prefered language

 

:)

 

This issue is presented in all 1.5 versions, it's not only 1.5.3 specific and there's still no solution.

 

Obviously they don't know how to fix it...

Edited by sofoklis (see edit history)
  • Like 2
Link to comment
Share on other sites

Some improvements to the comment of sofoklis

 

With my test I have achiveded to get products with friendly url and with all languages

 

I haven't use the point 2 in sofoklis instructions. Then I get the products in all languages

 

In point 3 I have added the 3 extra arguments but I haven't change the language reference. Maintain the (int)($product['id_lang'])

 

Then in line 201 more or less you have

// if the product has not been added

$id_product = $product['id_product'];

 

Below, you must add the line

$id_lang = $product['id_lang'];

and edit the next with

if (!isset($done[$id_product][$id_lang]['added']))

 

In line 215 more or less, in the same loop you find:

// considers the product has added

Then you must replace the next line with: $done[$id_product][$id_lang]['added'] = true;

 

With this 2 changes you add the product in every languagesto the array with friendly url

 

I haven't used the same logical for the image loop because then you duplicate the images in the sitemap, I don't know the efect in SEO

 

 

For the classic pages I have change temporaly Dispatcher.php .

 

In the function __construct ()

I have change the line 207-208 from:

$this->default_controller = 'adminhome';

$this->use_routes = false;

to

$this->default_controller = 'adminhome';

$this->use_routes = true;

 

Then I update the sitemap manually in the admin section: modules>gsitemap>configure>Update sitemap file

It make the urls correctly with my custom Format in SEO&URL,then I return the 208 line from dispatcher to false, because I don't know if it will make a fail in other places.

 

Apologies for my english

 

Fernando

  • Like 1
Link to comment
Share on other sites

@Chir2012 - I found the following solution in the forum, BUT it is still adding the EAN to the link, which I 've disabled for showing in BO. Somebody knows how to change the line for it ?

 

fix is modifying gsitemap.php in line 209 and change it to:

 

$tmpLink = $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($product['id_lang']),null,0,true);

  • Like 2
Link to comment
Share on other sites

Hi there, made just a rough test but set a null for

$product['ean13'] should do the trick:

$tmpLink = $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], null, (int)($product['id_lang']),null,0,true);

Best regards, trip

Edited by Trip (see edit history)
Link to comment
Share on other sites

Hi Trip,

 

thank you very much, yes this solves my problem.

 

Best regards

I have replaced line 209 with the code you provided and when i try to update my sitemap i get this error:

[PrestaShop] Fatal error in module gsitemap:

Call to a member function addChild() on a non-object

Any help? Thanks

Link to comment
Share on other sites

  • 1 month later...

I have modified some line

 

$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__.$lang['iso_code'].'/', '1.00', 'daily', date('Y-m-d'));

in

$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__."it".'/', '1.00', 'daily', date('Y-m-d'));

 

This fix the iso code, in my case.

 

Then, I change

LEFT JOIN '._DB_PREFIX_.'lang l ON (pl.id_lang = l.id_lang)

with

LEFT JOIN '._DB_PREFIX_.'lang l ON (pl.id_lang = 6)

and this fix the language of the product.

 

Now, my sitemap.xml is generated without apply the rules of rewriting and if I click in the link I have a 404 error.

Wrong sitemap:

http://mysite/it/index.php?controller=product_rule&id=2&rewrite=mini-piscina-idromassaggio-nuoto-controcorrente-bl858

 

Right sitemap:

http://mysite/it/index.php?controller=product_rule&id=2&rewrite=mini-piscina-idromassaggio-nuoto-controcorrente-bl858-p-2.html

 

 

Any suggestion? I need to open the new store... we lost a lot of money every day...

Link to comment
Share on other sites

I have modified some line

 

$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__.$lang['iso_code'].'/', '1.00', 'daily', date('Y-m-d'));

in

$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__."it".'/', '1.00', 'daily', date('Y-m-d'));

 

This fix the iso code, in my case.

 

Then, I change

LEFT JOIN '._DB_PREFIX_.'lang l ON (pl.id_lang = l.id_lang)

with

LEFT JOIN '._DB_PREFIX_.'lang l ON (pl.id_lang = 6)

and this fix the language of the product.

 

Now, my sitemap.xml is generated without apply the rules of rewriting and if I click in the link I have a 404 error.

Wrong sitemap:

http://mysite/it/ind...ocorrente-bl858

 

Right sitemap:

http://mysite/it/ind...-bl858-p-2.html

 

 

Any suggestion? I need to open the new store... we lost a lot of money every day...

 

Not necessary modifying this:

 

$langs = Language::getLanguages(); ->>>>> $langs[] = Language::getLanguage(6);

 

But the link to product and cms are still wrong.

The link to images works fine.

Edited by BL_promo (see edit history)
Link to comment
Share on other sites

Hi there, made just a rough test but set a null for

$product['ean13'] should do the trick:

$tmpLink = $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], 'null', (int)($product['id_lang']),null,0,true);

Best regards, trip

 

I tried this but now instead of EAN13 number i have "-null" added to the end of my URL :(

 

/id-product-name-null.html

 

How to get a rid of it?

Link to comment
Share on other sites

At Charlie, trie using null without the ' ' ... a maybe cleaner solution might look like

$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ?
 $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], null, (int)($product['id_lang']),null,0,true):
 $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($product['id_lang']));  

 

At the moment I am trying to get this up with multiple languages. It seems they did not have that in mind designing the module.

What I have so far is

  // adds the product
  if(count($langs) > 1)
   foreach($langs as $lang){
   $id_lang = $lang['id_lang'];
   $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ?
 $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], null, (int)($id_lang),null,0,true):
 $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($id_lang));   

   $sitemap = $this->_addSitemapNode($xml, $tmpLink, $priority, 'weekly', substr($product['date_upd'], 0, 10));
   }
  else{
   $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ?
 $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], null, (int)($product['id_lang']),null,0,true):
 $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($product['id_lang']));   
   }

but I have to add a function to get $product['link_rewrite'] in the right language and the image:caption and image:title are wrong too. Maybe I find a smarter way on doing this.

  • Like 2
Link to comment
Share on other sites

@Trip don't forget adding multilanguage rel=canonical for all enabled language pages, while using default language as default hreglang canonical url.

I cannot write code, but can contribute with some knowledge.

Link to comment
Share on other sites

Thank you Trip,

I've implemented this code and it's working fine now

 

$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ?
	 $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], null, (int)($product['id_lang']),null,0,true):
	 $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($product['id_lang'])); 

  • Like 1
Link to comment
Share on other sites

Thank you, charlie123, this code works fine.

 

Now, I have the last problem with sitemap: the link included are not correct, because they don't follow the directives of rewriting.

 

This is very important for me.

 

Then, if was possible to remove from sitemap the EAN... this is like a cherry on the top of the cake.

Link to comment
Share on other sites

Thank you, charlie123, this code works fine.

 

Now, I have the last problem with sitemap: the link included are not correct, because they don't follow the directives of rewriting.

 

This is very important for me.

 

Then, if was possible to remove from sitemap the EAN... this is like a cherry on the top of the cake.

 

The URL rewriting doesn't work with latest buggy PrestaShop 1.5.3.1

 

What I did, I've just edit the core file (which is not recommended but this is the only way for now) and I removed EAN13 from the link generator. Than the code above for sitemap will work fine and all your sitemap and product links will be correct (make sure you refresh your sitemap and htaccess file, cache etc). To see which code you will need to edit visit: http://www.prestashop.com/forums/index.php?/topic/215984-schema-of-urls-not-updating/page__view__findpost__p__1148382

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

This is module is so needed.

 

I have no sitemaps for 3 months and that is affecting to my SEO. I'm on a multishop+multilanguange environment...

 

If someone code a new third party module, it will have quite sales and money.

 

I don't know why Prestashop Team is not working on this. To have sitemaps on these days is indispensable for success.

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 6 months later...
×
×
  • Create New...