Thomas
Thomas

Reputation: 246

Magento extension just for single store in multishop

my client runs a multishop with very different products, different layouts and different domains. I developed an extension for the checkout process for one of the stores and now don't see a way to tell Magento only to work with this specific store.

I expect this to be mentioned in the /app/etc/modules/sampleextension.xml, but didn't find any information on this in the internet.

Is there a way to make an extension shop-specific?

Thanks Thomas

Upvotes: 3

Views: 3770

Answers (2)

Sylvain Rayé
Sylvain Rayé

Reputation: 2466

There are two solutions. 1) Programmatically: You can make any configuration field, store specific. And from that you can check, in code if you need to activate your module or not. With the file /app/code//yourcompany/yourmodule/etc/system.xml, thanks to the tags show_in_default, show_in_store, show_in_website, you can set a configuration field store view, website or by default.

So you must create a configuration field "active". It means that the path of the payment method configuration field "active" will be payment/yourpaymentname/active.

And from this path and if you have extended your payment class with the class Mage_Payment_Model_Method_Abstract, Magento will check if the payment module is available.

Check the class and method Mage_Payment_Model_Method_Abstract::isAvailable at the file app/code/core/Mage/Payment/Model/Method/Abstract.php

When you will configure your payment method in backend, you will have to set to "1" the field "active" for the store view or website or by default, following your wish.

Here an example for the configuration file system.xml for your payment module

<config>
   <sections>
    <payment translate="label" module="payment">
        <label>Payment Methods</label>
        <tab>sales</tab>
        <frontend_type>text</frontend_type>
        <sort_order>400</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
        <groups>
            <yourpaymentname translate="label">
                <label>Your new Payment method</label>
                <frontend_type>text</frontend_type>
                <sort_order>1</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                <fields>
                    <active translate="label">
                        <label>Enabled</label>
                        <frontend_type>select</frontend_type>
                        <source_model>adminhtml/system_config_source_yesno</source_model>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </active>
            <yourpaymentname>
        </groups>
        ....
    </sales>
<sections>

2) The second solution can be done through the backend, the easiest way maybe, in the tab Advanced of the configuration page, at the bottom left of the configuration page. You will have a list of all enabled or disabled modules in your shop. You select which store view you want to display or not, in the store switcher, at the top left of the page then you choose which module to enable or not thanks to the drop down menu in front of each module name.

Hope it helps Regards

Upvotes: 4

OSdave
OSdave

Reputation: 8585

you could/should have a "active" field, in your system.xml, which'd be a dropdown "yes/no", and then you can (des)active it for every website/store/store view.
Of course in some strategic points of your code you will check if it's active for this view :)

Upvotes: 0

Related Questions