Child pages
  • Specifics of multistore module development

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the few occasions where you need to apply a new value to the same Configuration variable for all existing stores, using the Configuration::updateGlobalValue($key, $value) method.

Handling images and other types of files

...

  • $share: is used to add a "WHERE" clause indicating that we are in the same group as the current store.
  • $alias:   is used to set the table alias to which the WHERE clause should be applied.

...

It makes it possible to add a JOIN clause to the  SQL query, joining between a table and its associated table in multistore mode.

For instance, this query automatically associates the _DB_PREFIX_.'product_shop' table to the _DB_PREFIX_.'product' table using the 'p' alias:

...

The method to use is Shop::addSqlRestrictionOnLang($alias = null, $id_shop = null).

It makes it possible to add a restriction on id_shop for a multishop lang language table.

For instance, this query automatically associates the _DB_PREFIX_.'product_lang' table to the _DB_PREFIX_.'wishlist_product' table using the 'pl' alias:

Code Block
'SELECT wp.`id_product`
 FROM `'._DB_PREFIX_.'wishlist_product` wp
 LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = wp.`id_product`
 '.Shop::addSqlAssociation('product', 'p').'
 LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Shop::addSqlRestrictionOnLang('pl').'
 WHERE pl.`id_lang` = '.(int)($id_lang);

...