I am using the following code to add products to Quote
object which throws an error if the product is out of stock
.
/** @var \Magento\Catalog\Model\Product $product */
$product->setTaxClassId($this->getTaxClassId())
->setPrice($price)
->setSpecialPrice($price)
->setTierPrice([])
->setBasePrice($baseprice)
->setOriginalCustomPrice($price)
->setRowTotal($rowTotal)
->setBaseRowTotal($rowTotal);
/** @var \Magento\Quote\Model\Quote $quote */
$quote->addProduct($product, (int)$qty);
How do I override the product qty check and create a backorder
for each case ?
backorder
field value toAllow Qty Below 0 and Notify Customer
.configuration
, but I need to override it irrespective ofAllow Qty Below 0 and Notify Customer
.programmatically
.Open a product at admin, From Inventory section , make backorder field value to Allow Qty Below 0 and Notify Customer