Hey. I myself am not a programmer, but an SEO, and I’m still not at the highest level in the code, so I rested on such a problem. It is necessary to make a multilingual hreflang markup on prestashop. I noticed that the prestashop base module "Language Picker" is almost completely sharpened. I corrected a little and got:
{foreach from=$languages key=k item=language name="languages"} {if $language.iso_code != $lang_iso} {assign var=indice_lang value=$language.id_lang} {if isset($lang_rewrite_urls.$indice_lang)} <link href="{$lang_rewrite_urls.$indice_lang|escape:htmlall}" rel="alternate" hreflang="{$language.iso_code|escape:'html':'UTF-8'}"> {else} <link href="{$link->getLanguageLink($language.id_lang)|escape:htmlall}" rel="alternate" hreflang="{$language.iso_code|escape:'html':'UTF-8'}"> {/if} {/if} {if $language.iso_code != $lang_iso} {/if} {/foreach} BUT! the problem is that I did not take into account the fact that the function was made so that the first line would not generate a link (there was no output of the link to the current page, so that the page would not refer to itself - for search robots).
<link href="{$lang_rewrite_urls.$indice_lang|escape:htmlall}" rel="alternate" hreflang="{$language.iso_code|escape:'html':'UTF-8'}"> there is also php, but I don’t see the generation change parameters there (either they aren’t there or I don’t know them yet)
protected function _prepareHook($params) { $languages = Language::getLanguages(true, $this->context->shop->id); if (!count($languages)) return false; $link = new Link(); if ((int)Configuration::get('PS_REWRITING_SETTINGS')) { $default_rewrite = array(); if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int)Tools::getValue('id_product'))) { $rewrite_infos = Product::getUrlRewriteInformations((int)$id_product); foreach ($rewrite_infos as $infos) $default_rewrite[$infos['id_lang']] = $link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']); } if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int)Tools::getValue('id_category'))) { $rewrite_infos = Category::getUrlRewriteInformations((int)$id_category); foreach ($rewrite_infos as $infos) $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int)$id_category, $infos['link_rewrite'], $infos['id_lang']); } if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int)Tools::getValue('id_cms')) || ($id_cms_category = (int)Tools::getValue('id_cms_category')))) { $rewrite_infos = (isset($id_cms) && !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category); foreach ($rewrite_infos as $infos) { $arr_link = (isset($id_cms) && !isset($id_cms_category)) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $arr_link; } } $this->smarty->assign('lang_rewrite_urls', $default_rewrite); } return true; } The question is how to replace $ lang_rewrite_urls. $ Indice_lang or how to rewrite, so that the current page will be displayed Either score and call the current page through a new request
The output should receive:
<link href="http://site.com/ru/" rel="alternate" hreflang="ru"> <link href="http://site.com/uk/" rel="alternate" hreflang="uk"> And displays only alternative (provided that the page http://site.com/ru/ ):
<link href="http://site.com/uk/" rel="alternate" hreflang="uk"> thanks for the help