|
5 | 5 | */
|
6 | 6 | namespace Magento\CatalogSearch\Model\Indexer;
|
7 | 7 |
|
8 |
| -use Magento\Catalog\Api\Data\ProductInterface; |
9 | 8 | use Magento\CatalogSearch\Model\Indexer\Fulltext\Action\FullFactory;
|
10 | 9 | use Magento\CatalogSearch\Model\Indexer\Scope\State;
|
11 | 10 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext as FulltextResource;
|
12 | 11 | use Magento\Framework\App\ObjectManager;
|
13 |
| -use Magento\Framework\EntityManager\MetadataPool; |
14 | 12 | use Magento\Framework\Search\Request\Config as SearchRequestConfig;
|
15 | 13 | use Magento\Framework\Search\Request\DimensionFactory;
|
16 | 14 | use Magento\Store\Model\StoreManagerInterface;
|
17 | 15 |
|
18 | 16 | /**
|
19 | 17 | * Provide functionality for Fulltext Search indexing.
|
20 |
| - * |
21 |
| - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
22 | 18 | */
|
23 | 19 | class Fulltext implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
|
24 | 20 | {
|
@@ -72,13 +68,6 @@ class Fulltext implements \Magento\Framework\Indexer\ActionInterface, \Magento\F
|
72 | 68 | */
|
73 | 69 | private $indexScopeState;
|
74 | 70 |
|
75 |
| - /** |
76 |
| - * Holder for MetadataPool instance. |
77 |
| - * |
78 |
| - * @var MetadataPool |
79 |
| - */ |
80 |
| - private $metadataPool = null; |
81 |
| - |
82 | 71 | /**
|
83 | 72 | * @param FullFactory $fullActionFactory
|
84 | 73 | * @param IndexerHandlerFactory $indexerHandlerFactory
|
@@ -133,37 +122,12 @@ public function execute($ids)
|
133 | 122 | ]);
|
134 | 123 | foreach ($storeIds as $storeId) {
|
135 | 124 | $dimension = $this->dimensionFactory->create(['name' => 'scope', 'value' => $storeId]);
|
136 |
| - $productIds = array_unique(array_merge($ids, $this->getRelationsByChild($ids))); |
| 125 | + $productIds = array_unique(array_merge($ids, $this->fulltextResource->getRelationsByChild($ids))); |
137 | 126 | $saveHandler->deleteIndex([$dimension], new \ArrayObject($productIds));
|
138 | 127 | $saveHandler->saveIndex([$dimension], $this->fullAction->rebuildStoreIndex($storeId, $ids));
|
139 | 128 | }
|
140 | 129 | }
|
141 | 130 |
|
142 |
| - /** |
143 |
| - * Retrieve product relations by children. |
144 |
| - * |
145 |
| - * @param int|array $childIds |
146 |
| - * @return array |
147 |
| - */ |
148 |
| - private function getRelationsByChild($childIds) |
149 |
| - { |
150 |
| - $connection = $this->fulltextResource->getConnection(); |
151 |
| - $linkField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField(); |
152 |
| - $select = $connection->select()->from( |
153 |
| - ['relation' => $this->fulltextResource->getTable('catalog_product_relation')], |
154 |
| - [] |
155 |
| - )->join( |
156 |
| - ['cpe' => $this->fulltextResource->getTable('catalog_product_entity')], |
157 |
| - 'cpe.' . $linkField . ' = relation.parent_id', |
158 |
| - ['cpe.entity_id'] |
159 |
| - )->where( |
160 |
| - 'relation.child_id IN (?)', |
161 |
| - $childIds |
162 |
| - )->distinct(true); |
163 |
| - |
164 |
| - return $connection->fetchCol($select); |
165 |
| - } |
166 |
| - |
167 | 131 | /**
|
168 | 132 | * Execute full indexation
|
169 | 133 | *
|
@@ -211,18 +175,4 @@ public function executeRow($id)
|
211 | 175 | {
|
212 | 176 | $this->execute([$id]);
|
213 | 177 | }
|
214 |
| - |
215 |
| - /** |
216 |
| - * Get Metadata Pool instance. |
217 |
| - * |
218 |
| - * @return MetadataPool |
219 |
| - */ |
220 |
| - private function getMetadataPool() |
221 |
| - { |
222 |
| - if ($this->metadataPool === null) { |
223 |
| - $this->metadataPool = ObjectManager::getInstance()->get(MetadataPool::class); |
224 |
| - } |
225 |
| - |
226 |
| - return $this->metadataPool; |
227 |
| - } |
228 | 178 | }
|
0 commit comments