Skip to content

Commit 72ed81c

Browse files
committed
MCP-584: Disable inventory check on quote load
- Enable Config option & remove validation for performance improvement
1 parent c8a9850 commit 72ed81c

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

app/code/Magento/Quote/Model/Config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function __construct(ScopeConfigInterface $config)
3535
*/
3636
public function isEnabled(): bool
3737
{
38-
//return (bool)$this->config->getValue(self::XML_PATH_INVENTORY_CHECK_ENABLED);
39-
return false;
38+
return (bool)$this->config->getValue(self::XML_PATH_INVENTORY_CHECK_ENABLED);
4039
}
4140
}

app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,16 @@ public function getStore()
318318
}
319319

320320
/**
321-
* Set and Validate Item Qty
321+
* Checking item data
322322
*
323-
* @return void
323+
* @return $this
324324
*/
325-
public function setQuantity()
325+
public function checkData()
326326
{
327327
$this->setHasError(false);
328328
$this->clearMessage();
329-
330329
$qty = $this->_getData('qty');
330+
331331
try {
332332
$this->setQty($qty);
333333
} catch (\Magento\Framework\Exception\LocalizedException $e) {
@@ -337,16 +337,7 @@ public function setQuantity()
337337
$this->setHasError(true);
338338
$this->setMessage(__('Item qty declaration error'));
339339
}
340-
}
341340

342-
/**
343-
* Checking item data
344-
*
345-
* @return $this
346-
*/
347-
public function checkData()
348-
{
349-
$this->setQuantity();
350341
try {
351342
$this->getProduct()->getTypeInstance()->checkProductBuyState($this->getProduct());
352343
} catch (\Magento\Framework\Exception\LocalizedException $e) {

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ protected function _assignProducts(): self
293293
$item->setQtyOptions($qtyOptions)->setProduct($product);
294294
if ($this->config->isEnabled()) {
295295
$item->checkData();
296-
} else {
297-
$item->setQuantity();
298296
}
299297
}
300298
}

0 commit comments

Comments
 (0)