|
6 | 6 | namespace Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price;
|
7 | 7 |
|
8 | 8 | use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BasePriceModifier;
|
| 9 | +use Magento\Framework\DB\Select; |
9 | 10 | use Magento\Framework\Indexer\DimensionalIndexerInterface;
|
10 | 11 | use Magento\Framework\EntityManager\MetadataPool;
|
11 | 12 | use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer;
|
@@ -140,6 +141,30 @@ public function executeByDimensions(array $dimensions, \Traversable $entityIds)
|
140 | 141 | $this->applyConfigurableOption($temporaryPriceTable, $dimensions, iterator_to_array($entityIds));
|
141 | 142 | }
|
142 | 143 |
|
| 144 | + /** |
| 145 | + * Filter select by inventory |
| 146 | + * |
| 147 | + * @param Select $select |
| 148 | + * @return Select |
| 149 | + */ |
| 150 | + public function filterSelectByInventory(Select $select) |
| 151 | + { |
| 152 | + $select->join( |
| 153 | + ['si' => $this->getTable('cataloginventory_stock_item')], |
| 154 | + 'si.product_id = l.product_id', |
| 155 | + [] |
| 156 | + ); |
| 157 | + $select->join( |
| 158 | + ['si_parent' => $this->getTable('cataloginventory_stock_item')], |
| 159 | + 'si_parent.product_id = l.parent_id', |
| 160 | + [] |
| 161 | + ); |
| 162 | + $select->where('si.is_in_stock = ?', Stock::STOCK_IN_STOCK); |
| 163 | + $select->orWhere('si_parent.is_in_stock = ?', Stock::STOCK_OUT_OF_STOCK); |
| 164 | + |
| 165 | + return $select; |
| 166 | + } |
| 167 | + |
143 | 168 | /**
|
144 | 169 | * Apply configurable option
|
145 | 170 | *
|
@@ -200,12 +225,7 @@ private function fillTemporaryOptionsTable(string $temporaryOptionsTableName, ar
|
200 | 225 |
|
201 | 226 | // Does not make sense to extend query if out of stock products won't appear in tables for indexing
|
202 | 227 | if ($this->isConfigShowOutOfStock()) {
|
203 |
| - $select->join( |
204 |
| - ['si' => $this->getTable('cataloginventory_stock_item')], |
205 |
| - 'si.product_id = l.product_id', |
206 |
| - [] |
207 |
| - ); |
208 |
| - $select->where('si.is_in_stock = ?', Stock::STOCK_IN_STOCK); |
| 228 | + $select = $this->filterSelectByInventory($select); |
209 | 229 | }
|
210 | 230 |
|
211 | 231 | $select->columns(
|
|
0 commit comments