【问题标题】:Magento: Custom "Out of Stock" message not disabled with product becomes in stockMagento:未随产品禁用的自定义“缺货”消息变为有货
【发布时间】:2012-09-29 00:59:17
【问题描述】:

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

自定义行为: 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.这必须在产品上明确完成。

--

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

【问题讨论】:

    标签: magento sap product inventory stock


    【解决方案1】:

    如果数量>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();
    }
    

    【讨论】:

    • 您的解决方案似乎合乎逻辑。但是,有人告诉我这应该是 magento 中的默认行为,并且必须清除缓存才能禁用自定义“缺货”消息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-30
    • 2015-04-02
    • 2014-08-29
    • 2011-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多