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
2 Answers
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:
\Mage_CatalogInventory_Model_Observer::checkQuoteItemQty()
and implement your own with your qty. The problem is, the actual check is made here:
\Mage_CatalogInventory_Model_Stock_Item::checkQty()
so the alternative is, to rewrite the catalog_inventory/stock_item
model.
Further to Fabian's answer, you can see in Mage_CatalogInventory_Model_Stock_Item::checkQty
there is the following:
public function checkQty($qty)
{
if (!$this->getManageStock() || Mage::app()->getStore()->isAdmin()) {
return true;
}
if ($this->getQty() - $this->getMinQty() - $qty < 0) {
switch ($this->getBackorders()) {
case Mage_CatalogInventory_Model_Stock::BACKORDERS_YES_NONOTIFY:
case Mage_CatalogInventory_Model_Stock::BACKORDERS_YES_NOTIFY:
break;
default:
return false;
break;
}
}
return true;
}
This basically gives backorders a free pass on the quantity check.
To have the non-backorder checks (e.g. 'Some of the products are currently out of stock' and 'The requested quantity for product is not available') apply you need three things:
- a way to set the allowed backorder quantity per product.
- use this attribute in
checkQty
(or similar). - have
checkQty
returnfalse
if cart quantity + quantity sold exceeds allowed quantity.
More details here: https://magento.stackexchange.com/a/41361/788
An extension I wrote to do this is here: https://github.com/etailer/etailer_backorders