Is there a way to limit the backorder qty? ie: I want to allow a product to get back-ordered, but only by a few
Magento – Limit product backorder qty
backorderinventory
Related Solutions
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!
Best Answer
Not that I know.
hacky way
The easy way is to raise all your qty by X where X is the number of backorders you want to allow.
better way
But you could deactivate the observer which checks it:
and implement your own with your qty. The problem is, the actual check is made here:
so the alternative is, to rewrite the
catalog_inventory/stock_item
model.