11<?php
22/**
3- * @category Magento
4- * @package Magento_CatalogInventory
53 * Copyright © Magento, Inc. All rights reserved.
64 * See COPYING.txt for license details.
75 */
119namespace Magento \CatalogInventory \Model \Indexer \Stock \Action ;
1210
1311use Magento \Catalog \Api \Data \ProductInterface ;
12+ use Magento \Catalog \Model \Product \Type as ProductType ;
1413use Magento \Catalog \Model \ResourceModel \Indexer \ActiveTableSwitcher ;
15- use Magento \CatalogInventory \Model \Indexer \Stock \BatchSizeManagement ;
14+ use Magento \CatalogInventory \Model \Indexer \Stock \AbstractAction ;
15+ use Magento \CatalogInventory \Model \Indexer \Stock \Processor ;
1616use Magento \CatalogInventory \Model \ResourceModel \Indexer \Stock \DefaultStock ;
17- use Magento \Framework \ App \ ResourceConnection ;
17+ use Magento \CatalogInventory \ Model \ ResourceModel \ Indexer \ Stock \ StockInterface ;
1818use Magento \CatalogInventory \Model \ResourceModel \Indexer \StockFactory ;
19- use Magento \Catalog \Model \Product \Type as ProductType ;
19+ use Magento \Framework \App \DeploymentConfig ;
20+ use Magento \Framework \App \ObjectManager ;
21+ use Magento \Framework \App \ResourceConnection ;
2022use Magento \Framework \DB \Query \BatchIteratorInterface ;
2123use Magento \Framework \DB \Query \Generator as QueryGenerator ;
22- use Magento \Framework \Indexer \CacheContext ;
23- use Magento \Framework \Event \ManagerInterface as EventManager ;
2424use Magento \Framework \EntityManager \MetadataPool ;
25- use Magento \Framework \Indexer \BatchSizeManagementInterface ;
26- use Magento \Framework \Indexer \BatchProviderInterface ;
27- use Magento \Framework \App \ObjectManager ;
25+ use Magento \Framework \Event \ManagerInterface as EventManager ;
2826use Magento \Framework \Exception \LocalizedException ;
29- use Magento \CatalogInventory \Model \Indexer \Stock \AbstractAction ;
30- use Magento \CatalogInventory \Model \ResourceModel \Indexer \Stock \StockInterface ;
31- use Magento \Framework \App \DeploymentConfig ;
32- use Magento \CatalogInventory \Model \Indexer \Stock \Processor ;
27+ use Magento \Framework \Indexer \BatchProviderInterface ;
28+ use Magento \Framework \Indexer \BatchSizeManagementInterface ;
29+ use Magento \Framework \Indexer \CacheContext ;
3330
3431/**
3532 * Class Full reindex action
@@ -41,7 +38,7 @@ class Full extends AbstractAction
4138 /**
4239 * Action type representation
4340 */
44- const ACTION_TYPE = 'full ' ;
41+ public const ACTION_TYPE = 'full ' ;
4542
4643 /**
4744 * @var MetadataPool
@@ -125,7 +122,7 @@ public function __construct(
125122 $ this ->metadataPool = $ metadataPool ?: ObjectManager::getInstance ()->get (MetadataPool::class);
126123 $ this ->batchProvider = $ batchProvider ?: ObjectManager::getInstance ()->get (BatchProviderInterface::class);
127124 $ this ->batchSizeManagement = $ batchSizeManagement ?: ObjectManager::getInstance ()->get (
128- BatchSizeManagement ::class
125+ BatchSizeManagementInterface ::class
129126 );
130127 $ this ->batchRowsCount = $ batchRowsCount ;
131128 $ this ->activeTableSwitcher = $ activeTableSwitcher ?: ObjectManager::getInstance ()
@@ -151,6 +148,7 @@ public function execute($ids = null): void
151148 $ entityMetadata = $ this ->metadataPool ->getMetadata (ProductInterface::class);
152149
153150 $ columns = array_keys ($ this ->_getConnection ()->describeTable ($ this ->_getIdxTable ()));
151+ $ indexerTables = [];
154152
155153 /** @var DefaultStock $indexer */
156154 foreach ($ this ->_getTypeIndexers () as $ indexer ) {
@@ -165,7 +163,7 @@ public function execute($ids = null): void
165163 )
166164 );
167165
168- if (is_null ( $ batchRowCount) ) {
166+ if ($ batchRowCount === null ) {
169167 $ batchRowCount = isset ($ this ->batchRowsCount [$ indexer ->getTypeId ()])
170168 ? $ this ->batchRowsCount [$ indexer ->getTypeId ()]
171169 : $ this ->batchRowsCount ['default ' ];
@@ -202,8 +200,12 @@ public function execute($ids = null): void
202200 $ connection ->query ($ query );
203201 }
204202 }
203+
204+ $ indexerTables [] = $ indexer ->getMainTable ();
205205 }
206- $ this ->activeTableSwitcher ->switchTable ($ indexer ->getConnection (), [$ indexer ->getMainTable ()]);
206+
207+ $ indexerTables = array_unique ($ indexerTables );
208+ $ this ->activeTableSwitcher ->switchTable ($ this ->_getConnection (), $ indexerTables );
207209 } catch (\Exception $ e ) {
208210 throw new LocalizedException (__ ($ e ->getMessage ()), $ e );
209211 }
0 commit comments