Get Free Audit

Prestashop 1.5 Multistore Customization on a Per-Store Basis

Oct 10, 2012

404 Alex Simonchik

Prestashop 1.5 Multistore Customization on a Per-Store Basis

PrestaShop has done much work to ensure 1.4 version modules backward compatibility with 1.5 version. For example, module configuration is saved automatically based on a selected store. However, if your module contains a Prestashop tab, get ready for trouble.

The thing is, any class, responsible for tab display in a back-office, extended the AdminTab class before. But in PrestaShop 1.5 the approach has changed. There should be an inheritance from the AdminController class. On the other hand, it allowed reaching the separation of logic and presentation. We don’t see echo in the tab class at last! All we need to do now is to use $this->fields_list variable in a constructor to pass an array of grid field values:

$this->fields_form variable is used to display fields in renderForm() method (which is responsible for fields output when editing/adding an object). A lot of default tabs have the «Shop association» parameter which allows associating some kind of data with a concrete store right while creating a new content (or editing an existing one). To output this parameter in your own module, use the piece of code below in the renderForm() method:

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

After the parameter is outputted, reload 2 methods from AdminController in your tab class. These methods are protected function updateAssoShop($id_object) and protected function getSelectedAssoShop($table). Their realization differs from a default one in the fact that we remove Shop::isTableAssociated($this->table) in both classes because Shop::$asso_tables array doesn’t contain our table with the «_shop» postfix. There are no default possibilities to change this array.

The example given uses a separate table to connect stores and corresponding data for multistore possibilities realization

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

Post a new comment

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