开发者

get initial value of status when extending magento product _beforeSave() function

I'm extending the Mage_Catalog_Model_Product to perform a stock check whenever the product is saved, and if a product is in stock, it will not allow you to disable it.

This works fine, but I want to change the funct开发者_StackOverflow中文版ionality. I want to disallow the ability to disable when the product is in stock ONLY if the product wasn't already disabled. Is it possible to get the initial status value of the product, before the edit was made, from within the _beforeSave() function?


You should be able to load the product from the database again in _beforeSave(), to check the original value. Something like this:

$originalProduct = Mage::getModel('catalog/product')->load($this->getId());

You should be able to get the product's status that is still in the database this way, before the save() overwrites it. Hopefully. I have not tested this. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜