1

I have a Magento 2.2.2 website with different storeviews. I have made som custom modules. Is that possible to have my custom modules only work for a specific storeview?

2

IMO, the simplest way could be you can create an admin configuration via xml file (yes/no) in store view scope to enable module, then before doing any logic you can check that.

Here is an example https://www.mageplaza.com/magento-2-module-development/create-system-xml-configuration-magento-2.html

| improve this answer | |
  • 1
    Hi @Tiikeri the above link is working fine, but when i disable the module its the module is not disabling, it is in active mode. – shivashankar m Dec 28 '18 at 6:38
  • Hi @shivashankarm, I don't think disabled module then this configuration is automatically changed to no. When you set it via XML, this value will be saved in core_config_data table. If you checked that key like "helloworld/general/display_text" (following the link above) in core_config_table you may see it still is yes. There are 2 ways to solve that issue: 1. quick and dirty: manually set that value to false in the database. 2. better method is adding the check if the module is enable also. something like: if(module_active || helloworld/general/display_text === true) { // doing your magic } – Tiikeri Dec 28 '18 at 8:04
1

If the extension develope to work at store level, then you can easily do that things like this.

  1. Open admin and go to configuration of extension.

  2. Check is there any field to make extension enable/disable ?

  3. If the field is available, then choose the storeview from dropdown for which you want disable the extension.

  4. Now disable extension and save configuration.

make caching and indexing and then check.

| improve this answer | |
  • 1
    I guess the problem is exctally I don't know how to make my own custom module to work at store level :( – Magento Learner Jun 20 '18 at 14:49
  • for that, you need to ask separate question. So other also can help you. – Dhiren Vasoya Jun 21 '18 at 3:10
0

I would like to re-open this question. I have created module for Magento 2. I would like to extend it's functionality per store view. Is it possible to add this option to my existing module? My module is available in main menu - not in configuration page. Thanks for answers in advance.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.