This question was already asked, but I want to know is there some issue if I use following solution to limit the backorder qty:
I'll set "Qty for Item's Status to Become Out of Stock
" as negative number on Inventory tab of product edit page and re-assign this negative number via catalog_product_prepare_save
observer. Thanks.
-
Extension is available magentocommerce.com/magento-connect/…– Tahir YasinCommented Dec 9, 2015 at 10:53
1 Answer
Crazy timing - I had this problem today too!
I had opted for a similar solution when I found your question. I did some more digging to see what the root cause of this issue is:
Magento 1.7 CE/1.12 EE introduced this change.
app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
contains a function_filterStockData
that sets negative values ofmin_qty
to 0:
protected function _filterStockData(&$stockData)
{
if (is_null($stockData)) {
return;
}
if (!isset($stockData['use_config_manage_stock'])) {
$stockData['use_config_manage_stock'] = 0;
}
if (isset($stockData['qty']) && (float)$stockData['qty'] > self::MAX_QTY_VALUE) {
$stockData['qty'] = self::MAX_QTY_VALUE;
}
if (isset($stockData['min_qty']) && (int)$stockData['min_qty'] < 0) {
$stockData['min_qty'] = 0;
}
if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) {
$stockData['is_decimal_divided'] = 0;
}
}
The line in the 1.7.0.0 release notes for this is
Fixed: "Qty for Item's Status to Become Out of Stock" option works incorrect
.There is a similar function in the code for updating stock via the REST API.
There is a thread on the defunct magento boards about this, a poster mentions a bug report that was accepted to be fixed. I can't find any bug report. This still exists in 1.9 CE and 1.14 EE.
This behaviour exists in magento2.
I decided to override the Mage_Adminhtml_Catalog_ProductController
controller to create a _filterStockData
function without the replacement of min_qty
.
I wrote an extension to handle this and have put it up on Github here: https://github.com/etailer/etailer_backorders
I've not run in to any issues with negative values of min_qty
yet.
Update:
Allowing negative min_qty
doesn't limit the number of backorders that can be added to cart or sold. It also doesn't move products to out_of_stock
when qty
= min_qty
.
However I've added both these features to my extension so you can refer to that if you're after implementation ideas!