문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top