2

mage 2.1.7 "use Store code in URL" set to YES.

Have 3 stores, one for our default/original store at "/" with code "france" and one for our south korea and north korea stores.

The default store is currently accessible on "/" and "/france" and the other 2 stores on "/south-korea" and "/north-korea" - that's fine. But the default store should only be accessible on "/"

We can use nginx to rewrite the URL "/france" to "/" but the URLs generated by magento2 include the store code. Where do I override this behavior? thank you.

0

Instead of adding the store code via the magento setting why not just add the store codes for south korea and north korea via nginx rewrite rule that would alleviate your '/' issue at the very least. Then just set your base urls with the store codes in them.

-1

Preference \Magento\Store\Model\Store, override the following protected function.

protected function _updatePathUseStoreView($url)
{
    if ($this->isUseStoreInUrl()) {
        $url .= $this->getCode() . '/';
    }
    return $url;
}

with below code:

protected function _updatePathUseStoreView($url)
{
    if ($this->isUseStoreInUrl()) {
        if($this->getCode() == 'default'){
            $url .= '/';
        }else{
            $url .= $this->getCode() . '/';
        }

    }
    return $url;
}
  • Doesnt work with store switcher (the store code is pre-pended again) – George Dec 14 '17 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.