Jump to content

Problems with hreflang in products with combinations


Alternativo

Recommended Posts

  • 2 weeks later...

Hi,
Ensure that the getProductLink method is generating the full URL with the correct language code and combination parameters. If your products with combinations have unique URLs, each combination should have its own self-referential hreflang tag.

Now, Inside the product template, you need to ensure that the hreflang tags are properly generated for each language and each combination of the product. Here's how you can add a self-referential hreflang tag:
{foreach from=$languages item=language}
<link rel="alternate" hreflang="{$language.iso_code}" href="{$link->getProductLink($product.id_product, null, null, null, $language.id_lang)}" />
{/foreach}

  • Like 1
Link to comment
Share on other sites

  • 6 months later...
  On 8/9/2024 at 1:29 PM, Knowband Plugins said:

Привет,
убедитесь, что метод getProductLink генерирует полный URL с правильным кодом языка и параметрами комбинации. Если ваши продукты с комбинациями имеют уникальные URL, каждая комбинация должна иметь свой собственный самореферентный тег hreflang.

Теперь внутри шаблона продукта вам нужно убедиться, что теги hreflang правильно генерируются для каждого языка и каждой комбинации продукта. Вот как можно добавить самореферентный тег hreflang:
{foreach from=$languages item=language}
<link rel="alternate" hreflang="{$language.iso_code}" href="{$link->getProductLink($product.id_product, null, null, null, $language.id_lang)}" />
{/foreach}

Expand  

{$languages} is undefined when use it in the product.tpl

  • Like 1
Link to comment
Share on other sites

Sorry, Its seems you need to create the custom module to achieve the same. 

In the custom module, you need to register the displayHeaderHook and then you need to assign the $languages first from the hook like

$languages = Language::getLanguages(true, $this->context->shop->id);
$this->context->smarty->assign('languages' => $languages);

$this->context->smarty->assign('id_product' => Tools::getValue("id_product"));

Then you need to create the new template file & need to write the above code .

 

{foreach from=$languages item=language}
<link rel="alternate" hreflang="{$language.iso_code}" href="{$link->getProductLink($id_product, null, null, null, $language.id_lang)}" />
{/foreach}

 

  • Like 1
Link to comment
Share on other sites

  On 3/3/2025 at 4:56 PM, Knowband Plugins said:

Sorry, Its seems you need to create the custom module to achieve the same. 

In the custom module, you need to register the displayHeaderHook and then you need to assign the $languages first from the hook like

$languages = Language::getLanguages(true, $this->context->shop->id);
$this->context->smarty->assign('languages' => $languages);

$this->context->smarty->assign('id_product' => Tools::getValue("id_product"));

Then you need to create the new template file & need to write the above code .

 

{foreach from=$languages item=language}
<link rel="alternate" hreflang="{$language.iso_code}" href="{$link->getProductLink($id_product, null, null, null, $language.id_lang)}" />
{/foreach}

 

Expand  

Many thanks!

  • Like 1
Link to comment
Share on other sites

  On 3/3/2025 at 4:56 PM, Knowband Plugins said:

Sorry, Its seems you need to create the custom module to achieve the same. 

In the custom module, you need to register the displayHeaderHook and then you need to assign the $languages first from the hook like

$languages = Language::getLanguages(true, $this->context->shop->id);
$this->context->smarty->assign('languages' => $languages);

$this->context->smarty->assign('id_product' => Tools::getValue("id_product"));

Then you need to create the new template file & need to write the above code .

 

{foreach from=$languages item=language}
<link rel="alternate" hreflang="{$language.iso_code}" href="{$link->getProductLink($id_product, null, null, null, $language.id_lang)}" />
{/foreach}

 

Expand  

The hreflangs URL are generates without combination paraments still using your code:

Page URL example: 

https://www.myshop.com/en/balance-line/111-3392-balance-line-balance-open-string-luxxa-lingerie.html

 

hreflangs: 

<link rel="alternate" hreflang="fr" href="https://www.myshop.com/fr/ligne-balance/111-ligne-balance-string-ouvert-balance-luxxa-lingerie.html">

<link rel="alternate" hreflang="en" href="https://www.myshop.com/en/balance-line/111-balance-line-balance-open-string-luxxa-lingerie.html">

  • Like 1
Link to comment
Share on other sites

  On 3/3/2025 at 5:54 PM, brain92 said:

The hreflangs URL are generates without combination paraments still using your code:

Page URL example: 

https://www.myshop.com/en/balance-line/111-3392-balance-line-balance-open-string-luxxa-lingerie.html

 

hreflangs: 

<link rel="alternate" hreflang="fr" href="https://www.myshop.com/fr/ligne-balance/111-ligne-balance-string-ouvert-balance-luxxa-lingerie.html">

<link rel="alternate" hreflang="en" href="https://www.myshop.com/en/balance-line/111-balance-line-balance-open-string-luxxa-lingerie.html">

Expand  

I think is needed to put id_product_attribute of current product page to the getProductLink  

Link to comment
Share on other sites

  On 3/3/2025 at 6:28 PM, brain92 said:

I think is needed to put id_product_attribute of current product page to the getProductLink  

Expand  

The next modification of the getProductLink works: {$link->getProductLink($product.id_product, null, null, null, $language.id_lang, null, $product.id_product_attribute)}. I get the next hreflangs: <link rel="alternate" hreflang="fr" href="https://www.shop-example.fr/fr/ligne-borsalino/71-9232-ligne-borsalino-collier-epaulettes-borsalino-luxxa-lingerie.html#/color-black/harness_size-m">

But i added the "null" to the sixth parametr of the function getProductLink. The sixth parament is $idShop.

Link to comment
Share on other sites

  On 3/3/2025 at 6:38 PM, brain92 said:

The next modification of the getProductLink works: {$link->getProductLink($product.id_product, null, null, null, $language.id_lang, null, $product.id_product_attribute)}. I get the next hreflangs: <link rel="alternate" hreflang="fr" href="https://www.shop-example.fr/fr/ligne-borsalino/71-9232-ligne-borsalino-collier-epaulettes-borsalino-luxxa-lingerie.html#/color-black/harness_size-m">

But i added the "null" to the sixth parametr of the function getProductLink. The sixth parament is $idShop.

Expand  

But the id of attributes didn't add and attributes names are not translated. Instead of "color-black/harness_size-m" at the end URL must be "11-couleur-noir/148-taille_de_harnais-m"

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