M2: How to get total stock qty

I will try get total stock product qty. I use this below code: <?php echo “Total qty: “; ?> <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $StockState = $objectManager->get(‘\Magento\CatalogInventory\Api\StockStateInterface’); echo $StockState->getStockQty($productId); ?> But script display 0 qty for all products. Here is full file code: <?php $_helper = \Magento\Framework\App\ObjectManager::getInstance()->get(‘Magento\Catalog\Helper\Output’); $_product = $this->getProduct(); $options = $_product->getOptions(); $matrix = $this->getPriceMatrix(2);…