12 use Magento\CatalogInventory\Model\ResourceModel\Stock\StatusFactory;
55 private $stockRegistryProvider;
60 private $stockConfiguration;
77 $this->stockRegistryProvider = $stockRegistryProvider;
90 $scopeId = $this->getStockConfiguration()->getDefaultScopeId();
91 $stockStatus = $this->stockRegistryProvider->getStockStatus(
$product->getId(), $scopeId);
92 $status = $stockStatus->getStockStatus();
106 $scopeId = $this->getStockConfiguration()->getDefaultScopeId();
109 $stockStatus = $this->stockRegistryProvider->getStockStatus(
$productId, $scopeId);
110 $status = $stockStatus->getStockStatus();
123 $manageStock = $this->scopeConfig->getValue(
124 \
Magento\CatalogInventory\Model\Configuration::XML_PATH_MANAGE_STOCK,
128 '{{table}}.use_config_manage_stock = 0 AND {{table}}.manage_stock=1 AND {{table}}.is_in_stock=1',
129 '{{table}}.use_config_manage_stock = 0 AND {{table}}.manage_stock=0' 133 $cond[] =
'{{table}}.use_config_manage_stock = 1 AND {{table}}.is_in_stock=1';
135 $cond[] =
'{{table}}.use_config_manage_stock = 1';
139 'inventory_in_stock',
140 'cataloginventory_stock_item',
142 'product_id=entity_id',
143 '(' . join(
') OR (', $cond) .
')' 155 $stockFlag =
'has_stock_status_filter';
157 $isShowOutOfStock = $this->scopeConfig->getValue(
158 \
Magento\CatalogInventory\Model\Configuration::XML_PATH_SHOW_OUT_OF_STOCK,
175 if (empty($this->stockStatusResource)) {
176 $this->stockStatusResource = $this->stockStatusFactory->create();
186 private function getStockConfiguration()
188 if ($this->stockConfiguration ===
null) {
190 ->get(\
Magento\CatalogInventory\Api\StockConfigurationInterface::class);
192 return $this->stockConfiguration;
__construct(StoreManagerInterface $storeManager, ScopeConfigInterface $scopeConfig, StatusFactory $stockStatusFactory, StockRegistryProviderInterface $stockRegistryProvider)
assignStatusToProduct(Product $product, $status=null)
addInStockFilterToCollection($collection)
addIsInStockFilterToCollection($collection)
addStockStatusToProducts(AbstractCollection $productCollection)