Jump to content
thirty bees forum

Question

Posted

I have installed a module that is great for multistore as it let me indicate which store version belongs to a specific language-country, so I can avoid duplicate content.

It creates a code like this:

    <link rel="alternate" hreflang="es-es" href="https://www.lesielle.com/es/" />
        <link rel="alternate" hreflang="fr-fr" href="https://www.lesielle.com/fr/" />
        <link rel="alternate" hreflang="fr-ch" href="https://www.lesielle.com/ch/fr/" />
        <link rel="alternate" hreflang="de-ch" href="https://www.lesielle.com/ch/de/" />
        <link rel="alternate" hreflang="de-de" href="https://www.lesielle.com/de/" />
        <link rel="alternate" hreflang="en-gb" href="https://www.lesielle.com/uk/" />
        <link rel="alternate" hreflang="es" href="https://www.lesielle.com/int/es/" />
        <link rel="alternate" hreflang="en" href="https://www.lesielle.com/int/en/" />
        <link rel="alternate" hreflang="fr" href="https://www.lesielle.com/int/fr/" />
        <link rel="alternate" hreflang="de" href="https://www.lesielle.com/int/de/" />
        <link rel="alternate" hreflang="en-us" href="https://www.lesielle.com/us/

But it seems also TB (I suppose it is TB) is creating alternative code for each language (not stores, only languages of the ACTUAL store. Even more, it indicate languages that are not being used in the actual store but they are activated in other stores):

How can I deactivate this code generation? Is less complete (doesn't include other stores) and also include information that it is not relevant (not activated languages)

NOTE: just to avoid misunderstood, /es/ is a store in the subdomain /es/, not Spanish language

10 answers to this question

Recommended Posts

  • 0
Posted

I am fighting with similair things (title attribute)... In your case it's probably not too hard. You should take a look at FrontController.php. There is a function called "getHrefLang".

  • 0
Posted

This is what I deleted:

public function getHrefLang($entity, $idItem, $languages, $idLangDefault) { $links = []; foreach ($languages as $lang) { switch ($entity) { case 'product': $lnk = $this->context->link->getProductLink((int) $idItem, null, null, null, $lang['idlang']); break; case 'category': $lnk = $this->context->link->getCategoryLink((int) $idItem, null, $lang['idlang']); break; case 'manufacturer': if (!$idItem) { $lnk = $this->context->link->getPageLink('manufacturer', null, $lang['idlang']); } else { $lnk = $this->context->link->getManufacturerLink((int) $idItem, null, $lang['idlang']); } break; case 'supplier': if (!$idItem) { $lnk = $this->context->link->getPageLink('supplier', null, $lang['idlang']); } else { $lnk = $this->context->link->getSupplierLink((int) $idItem, null, $lang['idlang']); } break; case 'cms': $lnk = $this->context->link->getCMSLink((int) $idItem, null, null, $lang['idlang']); break; case 'cmscategory': $lnk = $this->context->link->getCMSCategoryLink((int) $idItem, null, $lang['idlang']); break; default: $lnk = $this->context->link->getPageLink($entity, null, $lang['idlang']); break; }

        // append page number
        if ($p = Tools::getValue('p')) {
            $lnk .= "?p=$p";
        }

        $links[] = '<link rel="alternate" href="'.$lnk.'" hreflang="'.$lang['language_code'].'">';
        if ($lang['id_lang'] == $idLangDefault) {
            $links[] = '<link rel="alternate" href="'.$lnk.'" hreflang="x-default">';
        }
    }

    return $links;
}
  • 0
Posted

I would make on override if I were you. Try this one:

``` class FrontController extends FrontControllerCore {

public function getHrefLang($entity, $idItem, $languages, $idLangDefault)
{
    return null;
}

} ```

Save it under \override\controllers\front\FrontController.php

Dont forget to delete \cache\class_index.php on your server.

  • 0
Posted

This is what I deleted:

public function getHrefLang($entity, $idItem, $languages, $idLangDefault) { [...]

When removing code, one can remove code inside a function. If one remove the function its self, callers obviously fail.

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