Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Good question.</p> <p>I would have solved this problem on another way. Module structure:</p> <pre><code>Custom | - Module | - - Model | - - - Product.php | - - - Customer.php </code></pre> <p>For my opinion it is need to be created class that depends from store. If you want to create some functionality for Store UK, you need to declare this class for UK store, write it in configuration file and call it with factory class. For example in the config.xml</p> <pre><code> &lt;config&gt; &lt;stores&gt; &lt;store_uk&gt; &lt;catalog_product&gt;Custom_Module_Model_Store_Uk_Product&lt;/product_attribute&gt; &lt;customer&gt;Custom_Module_Model_Store_Uk_Customer&lt;/customer&gt; &lt;/store_uk&gt; &lt;store_en&gt; &lt;catalog_product&gt;Custom_Module_Model_Store_En_Product&lt;/catalog_product&gt; &lt;/store_en&gt; &lt;/stores&gt; &lt;/config&gt; </code></pre> <p>Create class store router:</p> <pre><code>class Custom_Module_Model_Store_Router { public function callMethod($method, $args) { if (strpos($method, '/') !== false) { $method = explode('/', $method); } if (count($method) != 2) { return false; } $handler = $method[0]; $method = $method[1]; $object = $this-&gt;_getObject($handler); if ($object) { //already checked if method exists retun $object-&gt;$method($args); } return false; } public function hasStoreMethod($method) { if (strpos($method, '/') !== false) { $method = explode('/', $method); } if (count($method) != 2) { return false; } $handler = $method[0]; $method = $method[1]; $object = $this-&gt;_getObject($handler); if (method_exists($object, $method)) { //Bingo return true; } return false; } protected function _getObject($handler) { $storeCode = Mage::app()-&gt;getStore(true)-&gt;getCode(); $handlerClassName = Mage::getStoreConfig($storeCode . '/' . $handler); if (empty($handlerClassName)) { return false; } $handlerInstance = Mage::getModel($handlerClassName); //here we can save instance into the _handlers etc. return $handlerInstance; } } </code></pre> <p>This class will be as default customization</p> <pre><code>//in your custom module product class Custom_Module_Model_Product extends Mage_Catalog_Model_Product_Attribute { public function getAttributes($groupId = null, $skipSuper = false) { $routerStore = Mage::getSingleton('custom_module/store_router'); if ($routerStore-&gt;hasStoreMethod('catalog_product/getAttributes')) { $attributes = $routerStore-&gt;callMethod('catalog_product/getAttributes', array('groupId' =&gt; $groupId, 'skipSuper' =&gt; $skipSuper)); return $attributes; } return parent::getAttributes($groupId, $skipSuper); } } </code></pre> <p>And this class is store Uk class only</p> <pre><code>//custom module product class for uk store Custom_Module_Model_Store_Uk_Product extends Mage_Catalog_Model_Product_Attribute { public function getAttributes($groupId = null, $skipSuper = false) { $attributes = parent::getAttributes($groupId, $skipSuper); // do some specific stuff return $attributes; } } </code></pre> <p>After this steps you will have clear customization classes with module structure listed below:</p> <pre><code>Custom | - Module | - - Model | - - - Store | - - - - Uk | - - - - - Product.php | - - - - - Customer.php | - - - - En | - - - - - Product.php | - - - - Router.php | - - - Product.php | - - - Customer.php </code></pre> <p>I hope this will help for your multistore development</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload