Magento中的核心替代 [英] Core overrides in Magento

查看:84
本文介绍了Magento中的核心替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我找到了关于动态期权定价的问题的答案,但是这使我陷入困境.我能理解大多数答案,但是当涉及到XML和模块实现时,我迷路了.

So I found an answer for a question I had about dynamic option pricing, but that lead to me being stumped. I can understand the majority of the answer, but when it comes to the XML and module implementation, I'm lost.

这就是我想要做的:

http://www.magentocommerce.com/boards/viewthread/260544/# t348802

需要覆盖 Mage_Catalog_Model_Product_Type_Price 模型和 Mage_Catalog_Block_Product_View_Options 块.

修改后的Price.php位于

Modified Price.php is located at

/app/core/local/rtega/dynamicPrice/Model/Product/Type/Price.php

/app/core/local/rtega/dynamicPrice/Model/Product/Type/Price.php

修改后的Options.php位于

Modified Options.php is located at

/app/core/local/rtega/dynamicPrice/Block/Product/View/Options.php

/app/core/local/rtega/dynamicPrice/Block/Product/View/Options.php

/app/etc/modules/

/app/etc/modules/

下面是

/app/core/local/rtega/dynamicPrice/etc/

/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".但这可能很好.

Firstly, I don't know how well Magento will handle your casing of "rtega" and "dynamicPrice". This might cause an issue either now or in the future. My recommended casing would be "Rtega" and "Dynamicprice". But it might be fine.

第二,您的块重写xml看起来不错,但是目录模型的重写不正确.我希望看到:

Secondly, your block rewrite xml looks fine, but the rewrite for the catalog Model is incorrect. I'd expect to see:

<config>
    ...
    <global>
        ...
        <models>
            <catalog>
                <rewrite>
                    <product_type_price>rtega_dynamicPrice_Model_Product_Type_Price</product_type_price>
                </rewrite>
            </catalog>
        </models>
        ...
    </global>
    ...
</config>

考虑这一点的最佳方法是首先将其分解为实例化原始模型的方式.在这种情况下,我们将呼叫

The best way to think about this is to break it down to how you instantiate the original model in the first place. In this case, we would call

Mage::getModel("catalog/product_type_price");

因此第一个xml节点是模型",因为这是一个模型,所以下一个xml节点是斜杠(目录)之前的部分,然后添加一个重写标签,然后在斜杠之后成为下一个xml节点,例如所以:

so the first xml node is "models", since this is a model, the next xml node is the portion before the slash (catalog), then add a rewrite tag, then after the slash becomes the next xml node, like so:

<models>
    <catalog>
        <rewrite>
            <product_type_price>

第三,在这种情况下,重要的是要看到您提到的文件位于:

Thirdly, in this instance it's important to see the files that you've mentioned are at:

/app/core/local/rtega/dynamicPrice/Model/Product/Type/Price.php and
/app/core/local/rtega/dynamicPrice/Block/Product/View/Options.php

如果您尚未这样做,则需要定义以下类:

If you're not already doing so, you need to define the classes like this:

class rtega_dynamicPrice_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price {

然后只需重新定义要修改的功能即可.

then just redefine the functions you want to modify.

希望这对您有所帮助!

这篇关于Magento中的核心替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆