【问题标题】:Override Product Price Template In Magento在 Magento 中覆盖产品价格模板
【发布时间】:2012-09-01 19:21:38
【问题描述】:

我试图在 Magento 中为 Product 和 Grid 页面隐藏所有产品的价格。我创建了一个自定义模块来更新布局,config.xml如下:

<config>
    <modules>
        <ABC_XYZ>
            <version>1.0</version>
        </ABC_XYZ>
    </modules>

    <frontend>
        <layout>
            <updates>
                <killprice>
                    <file>killprice.xml</file>
                </killprice>
            </updates>
        </layout>
    </frontend>

</config>

我添加 killprice.xml 如下:

<layout>


    <default>
        <block type="catalog/product_price_template" name="catalog_product_price_template"  template="killprice/price.phtml"  />
    </default>

    <killprice_index_index>
        <block type="catalog/product_price_template" name="catalog_product_price_template"  template="killprice/price.phtml"  />
    </killprice_index_index>

</layout> 

但是 killprice/price.phtml 没有被渲染,我得到了正常的价格模板。我对 killprice.xml 布局文件中的标签有点怀疑,我是否以正确的方式覆盖价格模板?

【问题讨论】:

    标签: magento


    【解决方案1】:

    这应该是你要找的……

    <layout>
        <default>
             <reference name="catalog_product_price_template">
                <action method="addPriceBlockType"><type>simple</type><block>catalog/product_price</block><template>killerprice/price.phtml</template></action>
                <!-- duplicate for each product type you need to handle i.e. change the value of the <type> node" -->
            </reference>
        </default>
    </layout>
    

    看看Mage_Catalog_Block_Product_Abstract 看看为什么会这样

    【讨论】:

    • simplecatalog/product_pricebundlecatalog/product_price这对我不起作用
    猜你喜欢
    • 1970-01-01
    • 2022-11-11
    • 2016-08-07
    • 1970-01-01
    • 2011-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-13
    相关资源
    最近更新 更多