2011-08-02 56 views
1

我在Magento模型重写中遇到问题。这里有两种自定义模块,在第一模块的config.xml我改写了核心模型Magento模型重写不起作用

<models> 
    <callforprice> 
     <class>Atwix_CallForPrice_Model</class> 
    </callforprice> 
    <catalog> 
     <rewrite> 
      <product>Atwix_CallForPrice_Model_Saleable</product> 
     </rewrite> 
    </catalog> 
</models> 

我也改写了核心区块

<blocks> 
    <callforprice> 
     <class>Atwix_CallForPrice_Block</class> 
    </callforprice> 
    <catalog> 
     <rewrite> 
      <product_list>Atwix_CallForPrice_Block_Product_List</product_list> 
     </rewrite> 
    </catalog> 
</blocks> 

getAddToCartUrl是功能,这是改写,这个功能改变“添加到购物车“按钮的URL。在这个模块中它工作正常。但是当我创建新的自定义模块并调用功能

$collection = Mage::getModel('catalog/product')->getCollection(); 

我没有得到所需的按钮的URL。与似乎重写不起作用。按钮仍然有核心的网址。我知道这是因为我在Atwix_CallForPrice_Block_Product_List中解析错误,以确保在第一个模块的情况下出现错误,在另一种情况下,所有工作都正常。

对不起,我的英语,伙计们。

+0

$ collection是否返回Mage_Catalog_Product或Atwix_CallForPrice_Model_Saleable的项目?这可能是你的问题的根源。 –

回答

0

我不确定,但也许你需要重写产品集合类。

+0

谢谢你们,我发现问题。问题的原因是在另一个文件中。这是我的失败。 – Nick