66namespace Magento \Catalog \Helper \Product \Flat ;
77
88use Magento \Framework \App \ResourceConnection ;
9+ use Magento \Framework \ObjectManager \ResetAfterRequestInterface ;
910
1011/**
1112 * Catalog Product Flat Indexer Helper
1516 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1617 * @since 100.0.2
1718 */
18- class Indexer extends \Magento \Framework \App \Helper \AbstractHelper
19+ class Indexer extends \Magento \Framework \App \Helper \AbstractHelper implements ResetAfterRequestInterface
1920{
2021 /**
2122 * Path to list of attributes used for flat indexer
2223 */
23- const XML_NODE_ATTRIBUTE_NODES = 'global/catalog/product/flat/attribute_groups ' ;
24+ public const XML_NODE_ATTRIBUTE_NODES = 'global/catalog/product/flat/attribute_groups ' ;
2425
2526 /**
2627 * Size of ids batch for reindex
2728 */
28- const BATCH_SIZE = 500 ;
29+ public const BATCH_SIZE = 500 ;
2930
3031 /**
3132 * Resource instance
@@ -49,7 +50,7 @@ class Indexer extends \Magento\Framework\App\Helper\AbstractHelper
4950 /**
5051 * Retrieve catalog product flat columns array in old format (used before MMDB support)
5152 *
52- * @return array
53+ * @var array
5354 */
5455 protected $ _attributes ;
5556
@@ -93,8 +94,6 @@ class Indexer extends \Magento\Framework\App\Helper\AbstractHelper
9394 protected $ _flatAttributeGroups = [];
9495
9596 /**
96- * Config factory
97- *
9897 * @var \Magento\Catalog\Model\ResourceModel\ConfigFactory
9998 */
10099 protected $ _configFactory ;
@@ -256,6 +255,7 @@ public function getFlatColumns()
256255 $ this ->isAddChildData ()
257256 )->getFlatColumns ();
258257 if ($ columns !== null ) {
258+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
259259 $ this ->_columns = array_merge ($ this ->_columns , $ columns );
260260 }
261261 }
@@ -332,6 +332,7 @@ public function getAttributeCodes()
332332
333333 foreach ($ this ->_flatAttributeGroups as $ attributeGroupName ) {
334334 $ attributes = $ this ->_attributeConfig ->getAttributeNames ($ attributeGroupName );
335+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
335336 $ this ->_systemAttributes = array_unique (array_merge ($ attributes , $ this ->_systemAttributes ));
336337 }
337338
@@ -416,6 +417,7 @@ public function getFlatIndexes()
416417 $ this ->isAddChildData ()
417418 )->getFlatIndexes ();
418419 if ($ indexes !== null ) {
420+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
419421 $ this ->_indexes = array_merge ($ this ->_indexes , $ indexes );
420422 }
421423 }
@@ -515,4 +517,13 @@ public function deleteAbandonedStoreFlatTables()
515517 $ connection ->dropTable ($ table );
516518 }
517519 }
520+
521+ /**
522+ * @inheritDoc
523+ */
524+ public function _resetState (): void
525+ {
526+ $ this ->_entityTypeId = null ;
527+ $ this ->_flatAttributeGroups = [];
528+ }
518529}
0 commit comments