0

How to display a label on a product if the saleable quantity is zero with the code?

1
  • are there any other approaches, like plugins or observers? May 12, 2022 at 5:51

1 Answer 1

0

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" ; 
  }
1
  • implemented but not working May 11, 2022 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.