How to add stock data of product using php in magento 2?
Just add this code into .phtml template
$stockItem = $_product->getExtensionAttributes()->getStockItem();
print_r($stockItem->getIsInStock());
additional data of stock:
echo $_productStock->getQty(); echo '<br />';
echo $_productStock->getMinQty(); echo '<br />';
echo $_productStock->getMinSaleQty(); echo '<br />';
echo $_productStock->getMaxSaleQty(); echo '<br />';
echo $_productStock->getIsInStock(); echo '<br />';