Class Stock @SuppressWarnings(PHPMD.CouplingBetweenObjects) @api
- Deprecated:
- 2.3.0 Replaced with Multi Source Inventory https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html
Definition at line 26 of file Stock.php.
◆ __construct()
- Parameters
-
StoreManagerInterface | $storeManager | |
ScopeConfigInterface | $scopeConfig | |
StatusFactory | $stockStatusFactory | |
StockRegistryProviderInterface | $stockRegistryProvider | |
Definition at line 68 of file Stock.php.
77 $this->stockRegistryProvider = $stockRegistryProvider;
◆ addInStockFilterToCollection()
addInStockFilterToCollection |
( |
|
$collection | ) |
|
Adds filtering for collection to return only in stock products
- Parameters
-
\Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection | $collection | |
- Returns
- void
Definition at line 121 of file Stock.php.
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) .
')'
◆ addIsInStockFilterToCollection()
addIsInStockFilterToCollection |
( |
|
$collection | ) |
|
Add only is in stock products filter to product collection
- Parameters
-
\Magento\Catalog\Model\ResourceModel\Product\Collection | $collection | |
- Returns
- void
Definition at line 153 of file Stock.php.
155 $stockFlag =
'has_stock_status_filter';
157 $isShowOutOfStock = $this->scopeConfig->getValue(
158 \
Magento\CatalogInventory\Model\Configuration::XML_PATH_SHOW_OUT_OF_STOCK,
◆ addStockStatusToProducts()
Add stock status information to products
- Parameters
-
AbstractCollection | $productCollection | |
- Deprecated:
- 100.1.0 Use Stock::addIsInStockFilterToCollection instead
- Returns
- void
Definition at line 104 of file Stock.php.
106 $scopeId = $this->getStockConfiguration()->getDefaultScopeId();
109 $stockStatus = $this->stockRegistryProvider->getStockStatus(
$productId, $scopeId);
110 $status = $stockStatus->getStockStatus();
◆ assignStatusToProduct()
assignStatusToProduct |
( |
Product |
$product, |
|
|
|
$status = null |
|
) |
| |
Assign stock status information to product
- Parameters
-
Product | $product | |
int | $status | |
- Returns
- void
Definition at line 87 of file Stock.php.
90 $scopeId = $this->getStockConfiguration()->getDefaultScopeId();
91 $stockStatus = $this->stockRegistryProvider->getStockStatus(
$product->getId(), $scopeId);
92 $status = $stockStatus->getStockStatus();
◆ getStockStatusResource()
getStockStatusResource |
( |
| ) |
|
|
protected |
- Returns
- Status
Definition at line 173 of file Stock.php.
175 if (empty($this->stockStatusResource)) {
176 $this->stockStatusResource = $this->stockStatusFactory->create();
◆ $scopeConfig
◆ $stockStatusFactory
◆ $stockStatusResource
◆ $storeManager
The documentation for this class was generated from the following file:
- vendor/magento/module-catalog-inventory/Helper/Stock.php