我鼓励这是第一次在这里发布一个问题,所以就这样了!
我是第一次尝试覆盖Magento核心课程; Mage_CatalogInventory_Model_Stock_Item位于@ /app/code/core/Mage/CatalogInventory/Model/Stock/Item.php,但出于某种原因,我没有成功执行;
$object = Mage::getModel('cataloginventory/stock_item');
var_dump(get_class($object));
输出
string 'Mage_CatalogInventory_Model_Stock_Item' (length=38)
我在/ app / code / local / Rage 下创建了一个新目录,并将Item.php复制到/app/code/local/Rage/CatalogInventory/Model/Stock/Item.php重命名它
class Rage_CatalogInventory_Model_Stock_Item extends Mage_CatalogInventory_Model_Stock_Item { ... }
我还制作了几个xml文件。一个到app / etc / modules / Rage_CatalogInventory.xml,其中包含以下内容;
<?xml version="1.0"?>
<config>
<modules>
<Rage_CatalogInventory>
<active>true</active>
<codepool>local</codepool>
</Rage_CatalogInventory>
</modules>
</config>
和另一个app / code / local / Rage / CatalogInventory / etc / config.xml;
<?xml version="1.0" ?>
<config>
<modules>
<rage_cataloginventory>
<version>0.0.1</version>
</rage_cataloginventory>
</modules>
<global>
<models>
<cataloginventory>
<rewrite>
<stock_item>Rage_CatalogInventory_Model_Stock_Item</stock_item>
</rewrite>
</cataloginventory>
</models>
</global>
</config>
即使经过几个小时的努力,我也无法让它发挥作用......这让我发疯了。希望你能帮助我!
许多人提前感谢。
编辑:修正了Amit指出的config.xml。原来,Magento使用了编译器。我发现可以解决这个问题。所以禁用了那个并清除了includes / src -folder内容,但仍然没有发生......
答案 0 :(得分:1)
问题,此处rage_cataloginventory
应为Rage_CatalogInventory
,此处为总config.xml
<?xml version="1.0" ?>
<config>
<modules>
<Rage_CatalogInventory>
<version>0.0.1</version>
</Rage_CatalogInventory>
</modules>
<global>
<models>
<cataloginventory>
<rewrite>
<stock_item>Rage_CatalogInventory_Model_Stock_Item</stock_item>
</rewrite>
</cataloginventory>
</models>
</global>
</config>
答案 1 :(得分:0)
好的,这只是一个猜测,如果我指出一些你明白的事情,就不要发疯;) 但是:你确实清除了配置缓存,对吗? (并且在开发环境中禁用编译器,如果忘记将其激活,可以省去一些麻烦。)
到目前为止,xml看起来非常正确,所以这不应该是问题。