我找到了有关动态期权定价问题的答案,但这让我感到困惑。我可以理解大部分答案,但是当涉及到 XML 和模块实现时,我迷失了。
这就是我正在尝试做的事情:
http://www.magentocommerce.com/boards/viewthread/260544/#t348802
需要覆盖 Mage_Catalog_Model_Product_Type_Price 模型和 Mage_Catalog_Block_Product_View_Options 块。
修改后的 Price.php 位于
/app/core/local/rtega/dynamicPrice/型号/产品/类型/Price.php
修改后的Options.php位于
/app/core/local/rtega/dynamicPrice/Block/Product/View/Options.php
有 rtega_dynamicPrice.xml
/应用程序/etc/modules/
下面是当前的 config.xml 位于
/app/core/local/rtega/dynamicPrice/etc/
<?xml version="1.0"?>
<config>
<modules>
<rtega_dynamicPrice>
<version>1.0.0</version>
</rtega_dynamicPrice>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<product_view_options>rtega_dynamicPrice_Block_Product_View_Options</product_view_options>
</rewrite>
</catalog>
</blocks>
<catalog>
<product>
<type>
<configurable>
<price_model>rtega_dynamicPrice_Model_Product_Type_Price</price>
</configurable>
</type>
</product>
</catalog>
</global>
</config>
非常感谢任何帮助!
需要提及的三件事。
首先,我不知道 Magento 将如何处理你的“rtega”和“dynamicPrice”的大小写。这可能会在现在或将来引起问题。我推荐的外壳是“Rtega”和“Dynamicprice”。但也许还好。
其次,您的块重写 xml 看起来不错,但目录模型的重写不正确。我希望看到:
<config>
...
<global>
...
<models>
<catalog>
<rewrite>
<product_type_price>rtega_dynamicPrice_Model_Product_Type_Price</product_type_price>
</rewrite>
</catalog>
</models>
...
</global>
...
</config>
考虑这个问题的最佳方法是首先将其分解为如何实例化原始模型。在这种情况下,我们会调用
Mage::getModel("catalog/product_type_price");
所以第一个xml节点是“models”,因为这是一个模型,所以下一个xml节点是斜杠之前的部分(目录),然后添加一个重写标签,然后斜杠之后成为下一个xml节点,如下所示:
<models>
<catalog>
<rewrite>
<product_type_price>
第三,在这种情况下,重要的是要查看您提到的文件位于:
/app/core/local/rtega/dynamicPrice/Model/Product/Type/Price.php and
/app/core/local/rtega/dynamicPrice/Block/Product/View/Options.php
如果您还没有这样做,您需要像这样定义类:
class rtega_dynamicPrice_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price {
然后重新定义你想要修改的函数即可。
希望这对您有所帮助!