In a Magento 2 multistore, is there a way to create a module 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. Is it possible to add some kind of rule into module.xml
or something like that to limit the scope of the module?
Best Answer
No, there is no rule you can set in
module.xml
to have a module enabled in one store only but you can do this:Create an
enabled/disabled
setting insystem.xml
in your module.Then in your class methods (not sure which ones because I don't know how your module works) do this:
First add
\Magento\Framework\App\Config\ScopeConfigInterface
as a dependency to your class:And for your methods that interact with Magento somehow (for example a frontend controller action, or an observer) you can do this: