<?php


namespace Magetop\Advancepreview\Helper;


use Magento\Framework\App\Helper\Context;

class ProductHelper extends \Magento\Framework\App\Helper\AbstractHelper
{
    protected $stockRegistry;
    public function __construct(
        Context $context,
        \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
    )
    {
        parent::__construct($context);
        $this->stockRegistry = $stockRegistry;
    }
    public function checkIsInStock($productId) {
        $stockItem = $this->stockRegistry->getStockItem($productId);
        $isInStock = $stockItem ? $stockItem->getIsInStock() : false;
        return $isInStock;
    }

}
