I need to get product quantity by using SKU. I have this code but give me null:
public function __construct(
\Magento\Catalog\Model\ProductRepository $productRepository,
array $data = []
)
{
$this->_productRepository = $productRepository;
}
public function getProductBySku($sku)
{
return $this->_productRepository->get($sku);
}
$_product = $this->getProductBySku($itm['sku']);
echo $_product->Qty();
$product->getQty()
?