/**
  * @param int $productId
  * @param int $scopeId
  * @return \Magento\CatalogInventory\Api\Data\StockStatusInterface
  */
 public function getStockStatus($productId, $scopeId)
 {
     $key = $scopeId . '/' . $productId;
     if (!isset($this->stockStatuses[$key])) {
         $criteria = $this->stockStatusCriteriaFactory->create();
         $criteria->setProductsFilter($productId);
         $criteria->setScopeFilter($scopeId);
         $collection = $this->stockStatusRepository->getList($criteria);
         $stockStatus = current($collection->getItems());
         if ($stockStatus && $stockStatus->getProductId()) {
             $this->stockStatuses[$key] = $stockStatus;
         } else {
             return $this->stockStatusFactory->create();
         }
     }
     return $this->stockStatuses[$key];
 }
 /**
  * @param int $productId
  * @param int $scopeId
  * @return \Magento\CatalogInventory\Api\Data\StockStatusInterface
  */
 public function getStockStatus($productId, $scopeId)
 {
     $stockStatus = $this->stockRegistryStorage->getStockStatus($productId, $scopeId);
     if (null === $stockStatus) {
         $criteria = $this->stockStatusCriteriaFactory->create();
         $criteria->setProductsFilter($productId);
         $criteria->setScopeFilter($scopeId);
         $collection = $this->stockStatusRepository->getList($criteria);
         $stockStatus = current($collection->getItems());
         if ($stockStatus && $stockStatus->getProductId()) {
             $this->stockRegistryStorage->setStockStatus($productId, $scopeId, $stockStatus);
         } else {
             $stockStatus = $this->stockStatusFactory->create();
         }
     }
     return $stockStatus;
 }