Error with the Minimum Quantity configuration for the product

Created by Esther Nguyen, Modified on Thu, 14 Oct 2021 at 02:38 PM by Esther Nguyen

ISSUE:

When I enter a Minimum Quantity for the product (in the admin for the product), and press save, the number just defaults back to 0.

What would cause this?


SOLUTION:

The reason for the issue is that the module has not created two columns: bss_minimum_qty_configurable and use_config_bss_minimum_qty_configurable. 

Besides, we found that the code that renders the minimum qty for each product using the foreach save can cause your site to break when the number of products is large. So, it is necessary to optimize the collection filter and query to update the save configuration faster. 


To resolve the issue, please edit the file /app/code/local/Bss/MinimumQtyConfigurable/Model/System/Config/Backend/Minqty.php as below: 


$stockItemCol = Mage::getResourceModel('cataloginventory/stock_item_collection');

        $stockItemCol->addFieldToFilter('type_id', array('eq' => Bss_MinimumQtyConfigurable_Model_Observer::TYPE_CONFIGURABLE));

        $stockItemCol->addFieldToFilter('use_config_bss_minimum_qty_configurable', array('eq' => 1));

        $connection = Mage::getSingleton('core/resource')->getConnection('core_write');

        $listItemId = $stockItemCol->getAllIds();

        if (!empty($listItemId)) {

            $listItemIds = implode(",", $listItemId);

            $sql = "UPDATE cataloginventory_stock_item SET bss_minimum_qty_configurable = ".(string)$minQty." WHERE item_id IN (".$listItemIds."); ";

            $connection->query($sql);

        }


If you need any further assistance, please feel free to contact us. We'd be happy to support you!



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article