How to get product backorders status in Magento 2?

You can know the Backorders status of the Product using Magento 2 by Product object.

First Load Product Object by product id or SKU. Now Fetch the extension attributes value of the Stock item from the Product object.

You can retrieve the value of the status of the backorders by Magento 2 with a return available value of 0, 1 and 2.

<?php
namespace Jesadiya\Backorders\Model;

use Psr\Log\LoggerInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;

class Backorders
{
    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * @var ProductRepositoryInterface
     */
    private $productRepository;

    public function __construct(
        LoggerInterface $logger,
        ProductRepositoryInterface $productRepository
    ) {
        $this->logger = $logger;
        $this->productRepository = $productRepository;
    }

    /**
     * Backorder status
     *
     * @return int
     */
    public function getBackordresStatus()
    {
        $productId = 1;
        $backorderStatus = 0;
        try {
            $product = $this->productRepository->getById($productId);
            $backorderStatus = $product->getExtensionAttributes()->getStockItem()->getBackorders();
        } catch (\Exception $exception) {
            $this->logger->error($exception->getMessage());
        }

        return $backorderStatus;
    }
}

You have to pass the product id to fetch product data, Now You can load the stock item extension attribute value from the Object.

Output: int Value.

0 => No Backorders
1 => Allow Qty Below 0
2 => Allow Qty Below 0 and notify customers