I’ve only recently started working with Magento and developement in general, so I am new at this. I need a (simple) product’s quantity for some custom logic. But I don’t know how to get it into my .phtml template. I used this function:
$quantity = $_product->getExtensionAttributes()->getStockItem()->getQty();
and
print_r($quantity);
to see what it returns… and it always returns 0, even if the item is in stock.
Then I tried
$quantity = $_product->getExtensionAttributes()->getStockItem()->getData();
print_r($quantity);
and got this:
literally everything except what I need :D.
While researching, I found a few people that said you need to create a module for this. Is this the only way? If so, how does one do this?
Thanks