99
1010use Aligent \PrerenderIo \Api \PrerenderClientInterface ;
1111use Aligent \PrerenderIo \Helper \Config ;
12- use Aligent \PrerenderIo \Helper \ProductIndexer as ProductIndexerHelper ;
1312use Aligent \PrerenderIo \Model \Url \GetUrlsForProducts ;
13+ use Magento \ConfigurableProduct \Model \Product \Type \Configurable ;
1414use Magento \Framework \App \DeploymentConfig ;
1515use Magento \Framework \Exception \FileSystemException ;
1616use Magento \Framework \Exception \LocalizedException ;
@@ -36,10 +36,8 @@ class ProductIndexer implements IndexerActionInterface, MviewActionInterface, Di
3636 private DeploymentConfig $ eploymentConfig ;
3737 /** @var Config */
3838 private Config $ prerenderConfigHelper ;
39- /**
40- * @var ProductIndexerHelper
41- */
42- private ProductIndexerHelper $ productIndexerHelper ;
39+ /** @var Configurable */
40+ private Configurable $ configurable ;
4341 /** @var int|null */
4442 private ?int $ batchSize ;
4543
@@ -50,6 +48,8 @@ class ProductIndexer implements IndexerActionInterface, MviewActionInterface, Di
5048 * @param PrerenderClientInterface $prerenderClient
5149 * @param DeploymentConfig $deploymentConfig
5250 * @param Config $prerenderConfigHelper
51+ * @param Configurable $configurable
52+ *
5353 * @param int|null $batchSize
5454 */
5555 public function __construct (
@@ -58,7 +58,7 @@ public function __construct(
5858 PrerenderClientInterface $ prerenderClient ,
5959 DeploymentConfig $ deploymentConfig ,
6060 Config $ prerenderConfigHelper ,
61- ProductIndexerHelper $ productIndexerHelper ,
61+ Configurable $ configurable ,
6262 ?int $ batchSize = 1000
6363 ) {
6464 $ this ->dimensionProvider = $ dimensionProvider ;
@@ -67,7 +67,7 @@ public function __construct(
6767 $ this ->deploymentConfig = $ deploymentConfig ;
6868 $ this ->batchSize = $ batchSize ;
6969 $ this ->prerenderConfigHelper = $ prerenderConfigHelper ;
70- $ this ->productIndexerHelper = $ productIndexerHelper ;
70+ $ this ->configurable = $ configurable ;
7171 }
7272
7373 /**
@@ -145,13 +145,11 @@ public function executeByDimensions(array $dimensions, \Traversable $entityIds):
145145 }
146146
147147 $ entityIds = iterator_to_array ($ entityIds );
148+
148149 // Include configurable product id(s) if the edited product is simple
149- foreach ($ entityIds as $ entityId ) {
150- $ parentEntityIds = $ this ->productIndexerHelper ->getParentEntityId ($ entityId );
151- if (!empty ($ parentEntityIds )) {
152- $ entityIds = array_merge ($ entityIds , $ parentEntityIds );
153- }
154- }
150+ $ parentIds = $ this ->configurable ->getParentIdsByChild ($ entityIds );
151+ $ entityIds = array_unique (array_merge ($ entityIds , $ parentIds ));
152+
155153 // get urls for the products
156154 $ urls = $ this ->getUrlsForProducts ->execute ($ entityIds , $ storeId );
157155
0 commit comments