Jump to content

Google sitemap friendly URL is not friendly


Recommended Posts

I just notice that the generated product URL in the sitemap.xml is not in friendly format (altho the friendly url in back office is activated),

 

so, instead

 

 

 

<url>
<loc>http://domain.com/store/music-ipods/1-ipod-nano.html</loc>
<priority>0.6</priority>
<lastmod>2012-12-11</lastmod>
<changefreq>weekly</changefreq>
</url>

 

it display

 

 

<url>
<loc>http://domain.com/index.php?id_product=1&controller=product</loc>
<priority>0.6</priority>
<lastmod>2012-12-11</lastmod>
<changefreq>weekly</changefreq>
</url>

 

my 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);

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

Hello,

 

 

Many thanks for pointing this out, I kind of missed that one!

 

From that I made some searches to find out that was known already and even reported. Anyway I am very grateful that you posted it or I would have for sure missed it for quite a long time, and google would have spanked me :D

 

I personally I also changed the sql query to make it 1 single language because I could not find a proper way to start with one specific language.

 

 

 

For reference in case someone would want to do the same:

 

replace

l.148 - $langs = Language::getLanguages();

by

 

l.148 + $langs[] = Language::getLanguage(<replace by id of the language you want>);

 

then replace

l.185 - WHERE l.`active` = 1

by

l.185 + WHERE l.id_lang = <replace by the id of the language you want>

 

 

Hope this helps & See you!

 

Cheers!

Link to comment
Share on other sites

  • 1 month later...

Hi, many thanks. This solves the problem of product controller, but how to eliminate the EAN in product link ? I tried to deleted in the line code

 

$product['ean13']

 

But than again the products are shown the link again with productcontroller instead of friendly.

Link to comment
Share on other sites

Hello,

 

 

Many thanks for pointing this out, I kind of missed that one!

 

From that I made some searches to find out that was known already and even reported. Anyway I am very grateful that you posted it or I would have for sure missed it for quite a long time, and google would have spanked me :D

 

I personally I also changed the sql query to make it 1 single language because I could not find a proper way to start with one specific language.

 

 

 

For reference in case someone would want to do the same:

 

replace

l.148 - $langs = Language::getLanguages();

by

 

l.148 + $langs[] = Language::getLanguage(<replace by id of the language you want>);

 

then replace

l.185 - WHERE l.`active` = 1

by

l.185 + WHERE l.id_lang = <replace by the id of the language you want>

 

 

Hope this helps & See you!

 

Cheers!

will this create the sitemap in one language only? thanks
Link to comment
Share on other sites

I just notice that the generated product URL in the sitemap.xml is not in friendly format (altho the friendly url in back office is activated),

 

so, instead

 

 

 

<url>
<loc>http://domain.com/store/music-ipods/1-ipod-nano.html</loc>
<priority>0.6</priority>
<lastmod>2012-12-11</lastmod>
<changefreq>weekly</changefreq>
</url>

 

it display

 

 

<url>
<loc>http://domain.com/index.php?id_product=1&controller=product</loc>
<priority>0.6</priority>
<lastmod>2012-12-11</lastmod>
<changefreq>weekly</changefreq>
</url>

 

my 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);

i replaced the code with your code, when i update sitemap i get this error:

[PrestaShop] Fatal error in module gsitemap:

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

 

any ideas?thanks

Link to comment
Share on other sites

Hello,

 

I used as fix (line 208):

 

$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (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']));

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

  • 3 weeks later...
  • 1 month later...
  • 4 weeks later...

Simply update the Google sitemap module in your module list. I think the current version is something like 2.1. After having updated, everything was fine with the sitemap (it even generate one sitemap per language of your prestashop).

Link to comment
Share on other sites

  • 1 year later...

Bonjour, je me permet de venir poser ma question ici car j'ai un gros soucis.

 le topic que j'ai ouvert à ce sujet

 

Aujourd'hui il m'est impossible d'avoir des urls corrects et ce, depuis la migration d'une 1.5 vers la 1.6.0.6. Même après avoir fait un test de migration vers la 1.6.0.8, les urls sont toujours problèmatiques, voici quelques exemples :

 

<loc><![CDATA[www.urldemonsite.fr/6-Array-3557640149011.html]]></loc>

<loc><![CDATA[www.urldemonsite.fr/9-Array-3557640149028.html]]></loc>

<image:loc><![CDATA[http://www.urldemonsite.fr/8538/Array.jpg]]></image:loc>

<image:loc><![CDATA[http://www.urldemonsite.fr/8547/Array.jpg]]></image:loc>

 

Je ne sais plus quoi faire...

merci d'avance

 

EDIT: Cela provenait d'un override de la class Meta.php et de la re-déclaration de la function __construct() dans mon override de Product.php
 

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

×
×
  • Create New...