2012-06-27 114 views
0

所以我找到了一個關於動態期權定價問題的答案,但這導致我被困住了。我可以理解大部分答案,但是當涉及到XML和模塊實現時,我就迷了路。Magento中的核心覆蓋

這裏就是我想要做的事:

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/Model/Product/Type/Price.php

改性選項。 php位於

/app/core/local/rtega/dyna micPrice /座/產品/瀏覽/ Options.php

有無rtega_dynamicPrice.xml在

/應用程序的/ etc /模塊/

下面是電流config.xml位於

/應用/核心/本地/ 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> 

任何幫助,不勝感激!

回答

3

有三件事要提。首先,我不知道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節點是「模型」,因爲這是一個模型,接下來的XML節點是斜槓(目錄)前面的部分,然後添加一個重寫標籤,斜線成爲下一個XML節點,像這樣再經過:

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

如果你是:

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

第三,在這種情況下它看到你所提到的文件是在是很重要的還沒有這樣做,你應該d來定義這樣的類:

class rtega_dynamicPrice_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price { 

然後只是重新定義你想修改的函數。

我希望這可以幫助你一些!

+0

自動裝載機不會喜歡小寫文件夾的名稱。 codePool下的所有文件夾和文件名必須在區分大小寫的文件系統上大寫。 – benmarks