Can't using plugin for checkQty in StockStateProvider Magento 2
-
10-10-2020 - |
문제
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
제휴하지 않습니다 magento.stackexchange