magento $this->_getProduct()->getStockItem() returns 重写后为空
magento $this->_getProduct()->getStockItem() returns null after rewrite
所以我想重写 CatalogInventory。我在 config.xml.
中使用以下代码重写了 2 个模型
<models>
<cataloginventory>
<rewrite>
<stock_item>Showoff_CatalogInventory_Model_Stock_Item</stock_item>
<observer>Showoff_CatalogInventory_Model_Observer</observer>
</rewrite>
</cataloginventory>
</models>
现在即使这些新模型是空的,它也不会再生成函数 getStockItem() 了。它总是 returns NULL。有货,缺货,10个有货 0个有货等等
编辑:
这是我的模块文件树的屏幕截图:
我的(空)模型:
Observer.php
class Showoff_CatalogInventory_Model_Observer
{
}
Stock/Item.php
class Showoff_CatalogInventory_Model_Stock_Item extends Mage_CatalogInventory_Model_Stock_Item
{
}
怎么会?请问有人可以帮我朝正确的方向踢吗?
提前致谢!!
你还应该扩展重写的 class
class Showoff_CatalogInventory_Model_Stock_Item extends Mage_CatalogInventory_Model_Stock_Item {
}
你也应该扩展重写的观察者。
所以我想重写 CatalogInventory。我在 config.xml.
中使用以下代码重写了 2 个模型<models>
<cataloginventory>
<rewrite>
<stock_item>Showoff_CatalogInventory_Model_Stock_Item</stock_item>
<observer>Showoff_CatalogInventory_Model_Observer</observer>
</rewrite>
</cataloginventory>
</models>
现在即使这些新模型是空的,它也不会再生成函数 getStockItem() 了。它总是 returns NULL。有货,缺货,10个有货 0个有货等等
编辑:
这是我的模块文件树的屏幕截图:
我的(空)模型:
Observer.php
class Showoff_CatalogInventory_Model_Observer
{
}
Stock/Item.php
class Showoff_CatalogInventory_Model_Stock_Item extends Mage_CatalogInventory_Model_Stock_Item
{
}
怎么会?请问有人可以帮我朝正确的方向踢吗?
提前致谢!!
你还应该扩展重写的 class
class Showoff_CatalogInventory_Model_Stock_Item extends Mage_CatalogInventory_Model_Stock_Item {
}
你也应该扩展重写的观察者。