Moving Forward with Magento, Part 2 – Implementing Store Views
In my previous blog article "Moving Forward with Magento, Part 1 – Implementing your Stores “Look and Feel” – Themes" I gave an overview of themes and their usage inside a Magento installation. The observant reader will have picked up that you can implement an unlimited number of Themes but only one shows for a particular store.
However, Magento allows you to implement multiple "store views", the power of this is not to be underestimated, you can have different themes and currencies for different stores, even different product sets or sub-sets of your products if you structure your catalogue carefully.
In this article I am going to present a technical section after the overview, if you are not technical then the "Concepts" sections will be most relevant to you.
The concept of store views is easy to grasp with the right examples. Let's say you want to have an Australian, New Zealand and USA themed store, specifically you want the product to show the relevant currency as the user will be able to equate this with other stores they might have looked at. Magento allows you to setup configuration for each store view, and this includes per store view themes and currency setup.
If you think of a store view being used to present multiple language or currency versions (or even a variation of the basic store theme) of your eCommerce site then you just need a mechanism to both configure the view and present the view back to users (which Magento provides). Store views can also be used to present Wholesale and Retail entry points or themed entry points for different community groups or product catelogies luckily Magento can do all of this.
This is just one of the many uses of store views, but they are a very powerful tool and knowing how to set them up is something all Magento Developers should know and all store owners should be aware of.
To implement store views you need to configure some sub-domains, configure the web server and configure Magento. When ever store view specific configuration is required, the ability to select the store view into the current scope is available.
Using the three store views example from above, we would need to have three sub-domains for our Magento store, generally I recomend a setup using a DNS name such as "us.<domain-name>" for the USA currency version, "nz.<domain-name>" for the New Zealand Vesion and "au.<domain-name>" for the Australian Version. I also recomend that you redirect www.<domain-name> just to <domain-name> and offer a language selection page that then takes you to the langauge of choice, redirection of the URL requires a change to the web server configuration. Otherwise you can also have currency selection on the Magento site using small Icons in the header area, this requires a template change by a developer. By using Magento you have a lot of flexiblity to do almost anything!
For each store view the base URL for the store needs to be set, in this example, the US store configuration is defined, you need to do this for every store view!
Web Server Configuration
The web server needs to know about the domain names you have configured, so that when a request arrives using a particular domain name, it can route it to Magento and set the correct store environment. Magento will then present the correct store view. In the web server this can be implemented in many ways, for the technically minded, I present details of this in a technical article detailing a procedure that can scale to 100's of domains if needed and is very clean to implement.
The Magento Setup is both rather simple and rather involved, you need to basically do the following tasks in order:
- First, define your website, store and store views as needed under Configuration -> Manage Stores.
- Next, configure each store view under Configuration ->System, then select each view and configure web, currency, design and general store information.
- Then, configure the currency rates, by going to Configuration -> Manage Currency -> Rates.
- Configure the products (Catalog – > Manage Products) to the required store views. Keep in mind that some products might not be allowed to be exported to the target country!
- Finally – TEST the site(s).
In the image above, we have defined each store view as well as an administration entry point, the use of environment codes is how Magento selects and renders the correct store. It can support an unlimited number of stores.
You will find that putting together a planning sheet will help to ensure that everything is done, you need to plan the environment codes that the web server passes to Magento to invoke the correct store view and that the web server configuration is done and then finally the sub-domain names are setup for live traffic to get to the stores.
Technical How To
Next week – How to actually implement the example store views from above.