Get Free Audit

How PrestaShop Supports Multistores in 1.5

Sep 24, 2012

997 Alex Simonchik

How PrestaShop Supports Multistores in 1.5

We won’t focus on back-office opportunities since you can get acquainted with solid documentation here. Let’s study technical issues of this opportunity instead.

The multistore feature allows you to manage several stores with one back-office. To start using a multistore, activate it in Preferences -> General -> Enable Multistore. If this feature is enabled, a Multistore tab will be available in the Advanced Parameters menu.

Now we can manage multistores via Advanced Parameters -> Multistore. Click the Add new shop link to create several stores.

Upon store creation, define its future URL by moving to Add URL.

This parameter is specified in the Virtual URI field. Our new store will be available under address, noted in the Your final URL will be field.

URL virtual data is stored in the database in the shop_url table.

multistores in prestashop

When a user jumps to some page, index.php file always appears as initial entry point unlike in a former PrestaShop version. Back then each controller was initiated in a corresponding file, for example,  product.php.:

Prestashop 1.4.x ->
require(dirname(__FILE__).’/config/config.inc.php’);     // initialization file activation
ControllerFactory::getController(‘ProductController’)->run();    //controller activation

PrestaShop 1.5.x ->
require(dirname(__FILE__).’/config/config.inc.php’);   // initialization file activation
Tools::displayFileAsDeprecated(); // displaying notification that the file used is outdated
Tools::redirect(‘index.php?controller=product’.($_REQUEST ? ‘&’.http_build_query($_REQUEST, ”, ‘&’) : ”), __PS_BASE_URI__, null, ‘HTTP/1.1 301 Moved Permanently’); // if a constant (_PS_DISPLAY_COMPATIBILITY_WARNING_) is set to FALSE, redirect to index.php with a specified controller will be performed instead of displaying an error.

Below I introduce the function that notifies about outdated controller request:

Note that the id_store parameter takes part in many SQL-requests in a new PrestaShop version. So how does the system understand which store data should be used? It happens in the config/config.inc.php file:


getContext() method returns us a singleton pattern. This method shows up in almost all PrestaShop controllers and classes.


Let’s examine the Shop::initialize(); method closely.

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

System defines in which store we are located based on id_store transfer or database info (on the grounds of function results Tools::getHttpHost (return the <b>current</b> host used)).

As you probably guessed, there are some changes in a database structure. Now one more table is added to every entity, except its own table where all data is stored. This new table includes differences for multiple stores and looks like a table with an entity name + store (example: attribute_group_shop, attribute_shop, carrier_shop, etc.). Let’s review it, using manufacturer as an example.

Configuration for the entire group:

BelVG manufacturer for Prestashop 1.5 store is missing.

BelVG manufacturer for Test store is available.

All manufacturers are presented in the manufacturer table.

Manufacturer_shop table points out connections between manufacturers and stores.

This was a quite simple case because store data is the same.

In the case of products, there is more data that will be different from store to store. That is why the product_shop  table contains more columns.

Please, keep in mind that product_shop stores data may vary from store to store. Let’s change the price of a MacBook in one of the stores. The expected result – product entry will remain unchanged in the product table while in the product_shop table we will see a new value.

Images above display different prices in different stores.

The following changes were detected in the database:

1) in the product_shop tables prices for different stores were changed
2) in the product table the result correlates with the last updated price

That’s all for now. I hope this post will help you comprehend a new model, used by PrestaShop. Would you like to make any corrections or do you disagree with me at some point? Feel free to tell me your opinion in the comment section below.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

4 Comments

  1. Pedro and benjamin, please contact us through our contact form.

    Zeljko, in the standard version you cant do this without Prestashop customization.

  2. Is it possible to make in the multistor following situation, we have a couple of stores, each with its own products and own subdomain and they have the same categories, but on the main domain it will show all the products from all stores from category that somebody select?

    Thank you in advance for every help

  3. All i read about multi store seems great, but not quite qhat i need. And seems much more simpler.
    We have a domain .com .pt and .es
    In prestashop 1.4 we had the module domainbylang which sorted the languages for each domain really well.
    If we clicked on another language, it would also change the domain.

    In multi store, it seems we need to create a store for each language, which makes no sense, since our prices are the same, template, stock, customers,…
    I’ve added the other 2 domain to the same shop, but the links for products, categories,… have the main url. And if i deactivate this i get a load of errors.

    In conclusion, prestashop developers should have thought about this situation. Specially since someone had a module for that usually means someone uses that feature…
    Pedro

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *