cancel
Showing results for 
Search instead for 
Did you mean: 

Change Store View Code to include a Hyphen (e.g. en-GB)

SOLVED

Change Store View Code to include a Hyphen (e.g. en-GB)

Dear community,

 

I'm looking for a way to change the Store View Code to include a hyphen instead of an underscore. Our shop has several Stores (i.e. representing different countries) and with several Store Views (i.e. the available languages). The URL format should look like this:

Example 1 (UK - English): https://www.demostore.com/en-GB/

Example 2 (Germany - German): https://www.demostore.com/de-DE/

Example 3 (Germany - English): https://www.demostore.com/en-DE/

 

Basically, the format for the Store View Code is as follows: language-COUNTRY

 

What is the best approach to solving this issue? I could potentially change the Store View Code manually in the DB but I'm not sure whether this will cause other issues down the road.

 

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Change Store View Code to include a Hyphen (e.g. en-GB)

@maxmosimann_1 ,

do not change the store code to en-GB keep them to en_gb 

all you need is the URL for your store as :

(UK - English): https://www.demostore.com/en-GB/ 

 

you can do that by following these steps:

  • create a new store view with store code en_gb
  • update the Base URL to  https://www.demostore.com/en-GB/ 
  • create a folder en-GB
  • copy index.php .htaccess to that folder and update the links into index.php with store code en_gb
  • create symlinks for media & static files within the en-GB folder
  • follow the same for all stores. 

kindly Accept as a Solution if this works for you and give Kudos Smiley Happy 

View solution in original post

Re: Change Store View Code to include a Hyphen (e.g. en-GB)

you need to check your document root for Magento 

Magento can run from the main folder as well as the pub folder. 

it's recommended to run from the pub folder. 

assuming you are using pub folder as a document root. 

 

 

cd magentoRootDir/pub
mkdir en-GB
cp index.php en-GB/
cp .htaccess en-GB/
cd en-GB/
ln -s ../media
ln -s ../static

now open en-GB/index.php 

 

and update the following line 

 

    require __DIR__ . '/../app/bootstrap.php';
-> 
    require __DIR__ . '/../../app/bootstrap.php';

 

 

View solution in original post

6 REPLIES 6

Re: Change Store View Code to include a Hyphen (e.g. en-GB)

@maxmosimann_1 ,

do not change the store code to en-GB keep them to en_gb 

all you need is the URL for your store as :

(UK - English): https://www.demostore.com/en-GB/ 

 

you can do that by following these steps:

  • create a new store view with store code en_gb
  • update the Base URL to  https://www.demostore.com/en-GB/ 
  • create a folder en-GB
  • copy index.php .htaccess to that folder and update the links into index.php with store code en_gb
  • create symlinks for media & static files within the en-GB folder
  • follow the same for all stores. 

kindly Accept as a Solution if this works for you and give Kudos Smiley Happy 

View solution in original post

Re: Change Store View Code to include a Hyphen (e.g. en-GB)

@amitsamsukha 

 

Thank you for your help!

Sorry, I'm pretty new to Magento (have been working with an ASP.Net e-commerce shop the past 4 years, that's why I need a bit more guidance).

 

Steps 1 and 2 are clear.

Step 3 (create a folder en-GB) -> I assume create a folder in Magento main file directory, can you confirm?

Step 4 -> I created the above folder in the Magento main file directory and copied index.php and .htaccess over to the en-GB (in my case the folder is called "ch-DE") folder. Can you explain in more detail how I can " update the links into index.php with store code en_gb"?

Step 5 -> Inside the ch-DE directory, I created a directory pub including the two symlinks to the folders /pub/media/ and /pub/static/ (via the terminal and command "ln -s pub/media/ ch-DE/pub/media")

 

Hope you can further assist.

 

Cheers

Re: Change Store View Code to include a Hyphen (e.g. en-GB)

you need to check your document root for Magento 

Magento can run from the main folder as well as the pub folder. 

it's recommended to run from the pub folder. 

assuming you are using pub folder as a document root. 

 

 

cd magentoRootDir/pub
mkdir en-GB
cp index.php en-GB/
cp .htaccess en-GB/
cd en-GB/
ln -s ../media
ln -s ../static

now open en-GB/index.php 

 

and update the following line 

 

    require __DIR__ . '/../app/bootstrap.php';
-> 
    require __DIR__ . '/../../app/bootstrap.php';

 

 

View solution in original post

Re: Change Store View Code to include a Hyphen (e.g. en-GB)

@amitsamsukha 

 

you're a champ - works perfectly fine - thanks a lot for your help!

Re: Change Store View Code to include a Hyphen (e.g. en-GB)

Hi @amitsamsukha 

I had successfully tested these changes on a dev server and that worked fine. Yesterday, I deployed these changes to our production server and now when navigating between the shops, I get a 404 not found ("Whoops, our bad..."). The URL in the browser changes to "https://www.demostore.com/en-AU/stores/store/redirect/". The only thing I did differently was on the dev server I changed the Base URL to https://www.demostore.com/en-AU/

whereas on the production server I let the Base URL as is and changed the Secure Base URL to https://www.demostore.com/en-AU/ instead

 

Would you happen to know why I cannot navigate between stores?

Re: Change Store View Code to include a Hyphen (e.g. en-GB)

Hello, I tried this solution but it's not working for me. 

Any other idea on how to bypass this problem? Is it just a matter of changing the validation function, or doing that could cause some other related issue with Magento?