How to display a label on a product if the saleable quantity is zero with the code?
-
are there any other approaches, like plugins or observers?– Pyaray AfzelMay 12 at 5:51
1 Answer
You have to override this file
/var/www/html/new_spectrum/vendor/magento/module-catalog/view/frontend/templates/product/list.phtml
in your theme Module_Catalog/view/product/list.phtml
This answer is useful
> <?php $objectManager =
> \Magento\Framework\App\ObjectManager::getInstance(); $StockState =
> $objectManager->get('\Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku');
> $qty = $StockState->execute($_product->getSku());
> $sale_qty = $qty[0]['qty'];
> if($sale_qty == 0) {
> echo "Do your code" ;
> }