cancel
Showing results for 
Search instead for 
Did you mean: 

M2 Multistore - Create module for one store only

M2 Multistore - Create module for one store only

In a Magento 2 multistore, is there a way to create a module that is available for one particular store only?

I know that I can disable a module using the admin, but that only disables the output of it. There must be possible to add some kind of rule into module.xml or something like that to limit the scope of the module. Thanks in advance.

3 REPLIES

Re: M2 Multistore - Create module for one store only

Hi @sebdecc,

 

What if you add, for example, an "Enable" flag to your module and allow the per store view level configuration.

Then you can validate if the module is available for that store view on frontend.

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: M2 Multistore - Create module for one store only

@Damian Culotta  thanks for the idea, I might try that.

 

I was actually looking for an out of the box functionality. I remember you could use the node restricted in Magento 1 to prevent your module to get loaded on certain stores. Something like:

 

<restricted>store_code</restricted>

But I wasn't able to find a similar option in Magento 2.

Re: M2 Multistore - Create module for one store only

@sebdeccI'm pretty sure you're talking about this: http://stackoverflow.com/questions/5962066/magento-disable-module-for-any-particular-store

 

I still believe that is better with configuration because you can reuse the module on another store. Also, if tomorrow you need te change that value, with your approach you'll need to redeploy files (and, in M2, recreate several files).

I think that using a database configuration could be easier to change the flag value without the need of deploys.

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"