在Magento中覆盖产品价格模板

Yeh*_*lam 0 magento

我试图在产品和网格页面中隐藏Magento中所有产品的价格.我创建了一个自定义模块来更新布局,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>
Run Code Online (Sandbox Code Playgroud)

我添加了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> 
Run Code Online (Sandbox Code Playgroud)

但是killprice/price.phtml没有呈现,我得到了正常的价格模板.我对killprice.xml布局文件中的标签有点怀疑,我是否正确地覆盖了价格模板?

Dre*_*ter 5

这应该是你要找的......

<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>
Run Code Online (Sandbox Code Playgroud)

在看看Mage_Catalog_Block_Product_Abstract,看看为什么这个作品