Question

I am trying to using plugin to return checkQty() to true to skip validate this but I can't. I don't know why?

public function aroundCheckQty($subject, callable $proceed, StockItemInterface $stockItem, $qty) { 
      return true; 
}

di.xml:

<type name="Magento\CatalogInventory\Model\StockStateProvider">
        <plugin name="QtyCheck" type="Bss\PreOrder\Plugin\QtyCheck" />
    </type>

Looking for help on this.

Was it helpful?

Solution

public function aroundCheckQty(\Magento\CatalogInventory\Model\StockStateProvider $subject, $proceed, \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem, $qty) 
{ 
   return true; 
}

In di.xml

<type name="Magento\CatalogInventory\Model\StockStateProvider">
    <plugin name="myQtyCheck" type="\VENDORNAME\MODULENAME\Plugin\QtyCheck" sortOrder="1"/>
</type>

If the above funciton is not working then try to clear cache, full page cache and Magento inventory model generation files in var/generation folder

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top