是否可以基于每个商店定义Magento布局更新

And*_*ter 6 magento

我有一个运行两个不同网站的Magento安装.一个销售电子书而另一个不销售,因此业务团队希望从应用程序的"我的帐户"区域中的客户导航块中删除"我的下载"链接.

我可以看到在design/frontend/base/layout/downloadable.xml中定义的链接,但看不到任何定义的方法,只允许我在其中一个网站上禁用链接.显然,我可以覆盖这个XML以关闭全局,但我需要将更改限制在范围内.

如何在多站点Magento安装中的单个网站或商店中定义布局覆盖?

根据以下答复,我做了以下工作:

创建了app/local/Mage/Customer/Block/Account/Navigation.php并添加了一个不在核心代码中的方法removeLink().

如果我在local.xml中进行了以下更改,则删除下载链接:

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        <remove name="catalog.compare.sidebar"/>
    </default>   
    <customer_account>
        <reference name="customer_account_navigation">
            <action method="removeLink" translate="label" module="downloadable"> <name>downloadable_products</name></action>
        </reference>
    </customer_account>
</layout>
Run Code Online (Sandbox Code Playgroud)

但是,如果尝试针对特定商店,则不是.例如

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        <remove name="catalog.compare.sidebar"/>
    </default>
    <STORE_mm>
    <customer_account>
        <reference name="customer_account_navigation">
            <action method="removeLink" translate="label" module="downloadable"> <name>downloadable_products</name></action>
        </reference>
    </customer_account>
    </STORE_mm>
</layout>
Run Code Online (Sandbox Code Playgroud)

ben*_*rks 9

正如Anton所说,为您的商店设置一个新的布局主题.任何站点范围+存储范围的方法的另一种方法是使用商店布局句柄 - 它就像<default>每个商店应用的句柄.如果您的商店代码(在Manage Stores> Store View下)是'foo',那么商店布局句柄就是<STORE_foo>.

参考. Mage_Core_Controller_Varien_Action::addActionLayoutHandles()