2

默认行为:当产品数量为 0 时 - 显示“缺货”消息。当产品有库存(由 SAP 更新库存)时,“缺货”消息会自动禁用。

Custom behavior: However, when a "custom out of stock" message is selected and the product becomes in stock, for whatever reason, the "custom out of stock" message is NOT disabled. 这必须在产品上明确完成。

--

寻找解决方案后,一种选择是购买/安装处理“缺货”产品的扩展程序,但有没有人在内部找到解决此问题的方法?

4

1 回答 1

1

如果 qty>0,您需要在更新期间将 is_in_stock 标志设置为“1”。如果您的代码无法做到这一点,那么您需要选择所有库存大于零的产品并将它们设置为 is_in_stock=1。您可以将其作为独立脚本运行,而不会对编写模块并将该模块放在 cron 作业中进行性能劣势,该作业将在您的更新完成后加入。这是伪代码:

$stockCollection = Mage::getModel('cataloginventory/stock_item')->getCollection()->addFieldToFilter('qty', array('gteq' => 1));

foreach($stockCollection as $item) {
    $item->setIsInStock(1)->save();
}
于 2012-10-08T19:46:02.213 回答