How to check product is in stock status programmatically Magento 2?

While developing on Magento 2 dependent on the Product stock status, In stock or Out of stock, you need to check it programmatically using StockRegistryInterface.

Use the Magento\CatalogInventory\Api\StockRegistryInterface class to fetch product stock status.

Let’s take a simple example by passing Product id, to check Product stock status,

Call method with a required parameter,

A result will be true if product qty greater than 0 or Stock Status set to In stock from the admin panel.

If Product Qty 0 or less than 0 or Stock status set to Out of stock Result will be false.

With the above code, snippet check the product stock status easily.

In this way Check Product stock status programmatically in your Block or Model file.