12 use Magento\CatalogInventory\Api\Data\StockInterfaceFactory;
13 use Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory;
14 use Magento\CatalogInventory\Api\Data\StockStatusInterfaceFactory;
15 use Magento\CatalogInventory\Api\StockCriteriaInterfaceFactory;
16 use Magento\CatalogInventory\Api\StockItemCriteriaInterfaceFactory;
17 use Magento\CatalogInventory\Api\StockStatusCriteriaInterfaceFactory;
116 $stock = $this->getStockRegistryStorage()->getStock($scopeId);
118 $criteria = $this->stockCriteriaFactory->create();
119 $criteria->setScopeFilter($scopeId);
120 $collection = $this->stockRepository->getList($criteria);
123 $this->getStockRegistryStorage()->setStock($scopeId,
$stock);
125 $stock = $this->stockFactory->create();
140 $criteria = $this->stockItemCriteriaFactory->create();
142 $collection = $this->stockItemRepository->getList($criteria);
147 $stockItem = $this->stockItemFactory->create();
160 $stockStatus = $this->getStockRegistryStorage()->getStockStatus(
$productId, $scopeId);
161 if (
null === $stockStatus) {
162 $criteria = $this->stockStatusCriteriaFactory->create();
164 $criteria->setScopeFilter($scopeId);
165 $collection = $this->stockStatusRepository->getList($criteria);
167 if ($stockStatus && $stockStatus->getProductId()) {
168 $this->getStockRegistryStorage()->setStockStatus(
$productId, $scopeId, $stockStatus);
170 $stockStatus = $this->stockStatusFactory->create();
179 private function getStockRegistryStorage()
181 if (
null === $this->stockRegistryStorage) {
183 ->get(\
Magento\CatalogInventory\Model\StockRegistryStorage::class);
getStockItem($productId, $scopeId)
$stockItemCriteriaFactory
getStockStatus($productId, $scopeId)
$stockStatusCriteriaFactory
__construct(StockRepositoryInterface $stockRepository, StockInterfaceFactory $stockFactory, StockItemRepositoryInterface $stockItemRepository, StockItemInterfaceFactory $stockItemFactory, StockStatusRepositoryInterface $stockStatusRepository, StockStatusInterfaceFactory $stockStatusFactory, StockCriteriaInterfaceFactory $stockCriteriaFactory, StockItemCriteriaInterfaceFactory $stockItemCriteriaFactory, StockStatusCriteriaInterfaceFactory $stockStatusCriteriaFactory)