Paid Media

Developer's Toolbox: Using Store Views in Magento

Sep 04, 2012   •   3 Min Read

Recently I have been working with a client to create additional store views as they expand their international presence. During the project, I realized that available information regarding this process is unreliable and decided to make it the topic of my newest blog post. In this entry we will cover creating a new store view in Magento, determine when a new website instance is required, and review different methods to configure your server to run the store.

Configure Magento

Believe it or not, this step is the easiest part of the process. From the Magento admin panel navigate to the System->Manage Stores.

Magento

At this point, you need to decide what you want from your new store. If you only want to display a new language you can skip ahead to the Create Store View section. If you are interested in changing product prices or plan on adding new products just for this store view you will need to create a new website and store in your Magento instance.

Create Website

This will create a new website on your Magento instance. In this page you will need to enter a name for the new website, a code, and the sort order. The store name is self explanatory, the code is used by Magento to identify the website, and the sort order is used by the system to order all websites in the instance.

Magento

Create Store

This section assigns a root category to the website. The store requires a website and a root category to be selected and a name to be provided.

Magento

Root categories are the uppermost levels in a category hierarchy. If you wish your new store to have a different category structure you will need to create a new root category by going to Catalog->Categories->Manage Categories.

Magento

Create Store View

This is the lowest level of the Magento store hierarchy. Most Magento data, including categories and products, can be edited at this store view level. For a store view to be created it needs to be assigned to an existing store, and a unique name and store needs to be provided. In addition, this page allows store views to be enabled and disabled as needed.

Magento

Modify Store Url

Now that your store has been created, you need to tell Magento what the new store url should be. Navigate to System->Configuration, select the ‘Web’ page, and change the Current Configuration Scope to the new website (if you only created a new store view change the scope to that view). Make sure to uncheck the checkbox next to the Base URL and Secure URL and enter the new store’s address.

Magento

Implement New Package/Theme

If you want to use a new theme for your store view, navigate to System->Configuration and select the ‘Design’ page. Make sure you are in the correct configuration scope and modify the Package and/or Theme values to use your new design.

Magento

Webserver Configuration

Now that Magento knows everything it needs to, we need to determine how to configure your webserver. There are two popular methods being used by storeowners, using secondary domains and separate directories or pointer domains and .htaccess rules.

Secondary Domains

To use this you need to create a new directory and configure the server to send new url calls to that directory. Next, you will need to create a series of symlinks to the primary Magento instance. The following commands assume the current directory is the new store’s base directory and the primary Magento instance is one row above.

ln –s ../app app

ln –s ../includes includes

ln –s ../js js

ln –s ../lib lib

ln –s ../media media

ln –s ../skin skin

ln –s ../var var

In addition, you need to copy the .htaccess and index.php files from the base directory to the new directory. And finally, the final line of the new index.php file needs to be modified to use the new website code.

Mage::run(‘site_code’, ‘website’)

If you only created a store view, the line of code should actually be:

Mage::run(‘store_view_code’, ‘store’)

Pointer Domains

There are two ways to implement the pointer domain method. The first is very simple and uses the SetEnvIf directive to change variables in the index.php file. The second involves using RewriteCond and RewriteRule in the .htaccess file.

SetEnvIf Implementation

Add the following two lines just below the ‘RewriteEngine On’ line:

SetEnvIf Host .*newDomain.* MAGE_RUN_CODE=site_code

SetEnvIf Host .*newDomain.* MAGE_RUN_TYPE=website

Rewrite Implementation

Add the following code just below the RewriteBase /Magento line:

RewriteCond %{HTTP_HOST} .*newdomain\.com [NC]

RewriteRule .* - [E=MAGE_RUN_CODE:site_code]

RewriteCond %{HTTP_HOST} .*newdomain\.com [NC]

RewriteRule .* - [E=MAGE_RUN_TYPE:website]

If you are attempting to use the pointer domains method but only created a new store view, change the MAGE_RUN_CODE to the store view code and MAGE_RUN_TYPE to ‘store’.

Wrap-Up

To recap, we’ve run through the process of creating new store instances in the Magento system and walked through the steps required to configure the webserver. You should have everything they need to properly use the store functionality in Magento. If you have followed these steps and are still having problems getting your store to render properly feel free to post a comment below and I will do what I can to help.

To learn more on Magento website design and development read my last blog on the Price Rules in Magento where you will find a walkthrough explaining the functionality behind both shopping cart and catalog price rules.

Questions? We can help. Fill out the contact form below to get answers to any questions you have about Magento.

Explore more tags: Paid Media Blog
Related Content

You Also May Like

Blog

The 5 Best AI Video Tools for eCommerce Brands In 2023+

In the realm of digital content creation, video has emerged as a dominant force,...
Learn More
Blog

An eCommerce Agency's 5 Best Social Media AI Tools For Online Sales

In today's interconnected world, social media has transformed into an indispensable...
Learn More
Blog

The Best Product & Lifestyle Photography AI Tools for eCommerce Stores

T he rapidly evolving world of AI in eCommerce means that artificial intelligence...
Learn More
Blog

The History, Present, & Future of AI (Artificial Intelligence) and eCommerce

In today's fast-paced world, automation plays a vital role in various industries,...
Learn More
Blog

Visual Branding in eCommerce: Why It Matters

Online stores need to catch our attention and be memorable in order to stand out....
Learn More
Blog

Klaviyo CDP: Revolutionizing Customer Data Platforms for Enterprise Brands

Watch on YouTube Starting with the Basics: What is a CDP? To start, let's peel back...
Learn More
BigCommerce vs Shopify_ Everything You Need to Know - 524x352
eBook
E-BOOK

BigCommerce vs Shopify:
Everything You Need to Know

Download e-Book

Let's Grow Your eCommerce Business, Together.