【问题标题】:How rewrite Mage_Catalog_Block_Product_Price for handle catalog_product_view?如何为句柄catalog_product_view重写Mage_Catalog_Block_Product_Price?
【发布时间】:2013-09-24 21:22:08
【问题描述】:

如何只为句柄catalog_product_view重写Mage_Catalog_Block_Product_Price?此块在布局中没有特定名称。

<catalog_product_view>
    <reference name="???">
        <block type="test/price" name="test.price />
    </reference>        
</catalog_product_view>

【问题讨论】:

  • 你能指定你想做什么吗?
  • 我需要在 Mage_Catalog_Block_Product_Price 中重写 _toHtml() 以解析产品页面的 html(为 html 标签添加丰富的 sn-p 属性)

标签: html magento block


【解决方案1】:

由于在 magento 中产品类型定义了用于呈现价格的块,因此有点棘手。也许这可以工作:

转到您喜欢的布局 xml 文件并添加此文件

<catalog_product_view>
    <reference name="catalog_product_price_template">
        <action method="addPriceBlockType"><type>simple</type><block>yourmodule/catalog_product_price</block><template>catalog/product/price.phtml</template></action>
        <action method="addPriceBlockType"><type>virtual</type><block>yourmodule/catalog_product_price</block><template>catalog/product/price.phtml</template></action>
        <action method="addPriceBlockType"><type>grouped</type><block>yourmodule/catalog_product_price</block><template>catalog/product/price.phtml</template></action>
        <action method="addPriceBlockType"><type>downloadable</type><block>yourmodule/catalog_product_price</block><template>catalog/product/price.phtml</template></action>
        <action method="addPriceBlockType"><type>configurable</type><block>yourmodule/catalog_product_price</block><template>catalog/product/price.phtml</template></action>
        <action method="addPriceBlockType"><type>bundle</type><block>yourmodule/bundle_catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action>
    </reference>
</catalog_product_view>

我不是 100% 确定这会奏效,但它可能是你的开始

【讨论】:

  • 谢谢,你帮了大忙!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-25
  • 2011-06-06
  • 1970-01-01
  • 2014-05-22
  • 2020-05-12
  • 1970-01-01
相关资源
最近更新 更多