我的客户经营着一家拥有非常不同的产品、不同布局和不同领域的综合商店。我为其中一家商店的结账流程开发了一个扩展程序,但现在找不到告诉 Magento 只与这家特定商店合作的方法。
我希望在/app/etc/modules/sampleextension.xml 中提到这一点,但在互联网上没有找到任何相关信息。
有没有办法让商店特定的扩展?
谢谢 托马斯
最佳答案
有两种解决方案。 1)以编程方式: 您可以制作任何配置字段,特定于商店。如果您需要激活您的模块,您可以从中检查代码。 通过文件/app/code//yourcompany/yourmodule/etc/system.xml,借助标签 show_in_default、show_in_store、show_in_website,您可以设置配置字段商店 View 、网站或默认。
所以你必须创建一个配置字段“active”。这意味着支付方式配置字段“active”的路径将是payment/yourpaymentname/active。
从这条路径开始,如果您使用 Mage_Payment_Model_Method_Abstract 类扩展了支付类,Magento 将检查支付模块是否可用。
检查文件 app/code/core/Mage/Payment/Model/Method/Abstract.php 中的类和方法 Mage_Payment_Model_Method_Abstract::isAvailable
当您在后端配置您的支付方式时,您必须将商店 View 或网站的“事件”字段设置为“1”,或者根据您的意愿将其默认设置为“1”。
这里是您支付模块的配置文件 system.xml 的示例
<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) 第二种解决方案可以通过后端完成,最简单的方法可能是在配置页面左下角的高级选项卡中。 您将拥有商店中所有启用或禁用模块的列表。您可以在页面左上角的商店切换器中选择要显示或不显示的商店 View ,然后通过每个模块名称前面的下拉菜单选择要启用或不启用的模块。
希望对你有帮助 问候
关于magento-1.4 - Magento 扩展仅适用于 multishop 中的单个商店,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7823389/