5
5
*/
6
6
namespace Magento \Catalog \Model \Indexer \Category \Flat \Action ;
7
7
8
+ use Magento \Framework \App \ResourceConnection ;
9
+
10
+ /**
11
+ * Class for full reindex flat categories
12
+ */
8
13
class Full extends \Magento \Catalog \Model \Indexer \Category \Flat \AbstractAction
9
14
{
10
15
/**
@@ -19,6 +24,28 @@ class Full extends \Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction
19
24
*/
20
25
protected $ allowTableChanges = true ;
21
26
27
+ /**
28
+ * @var \Magento\Catalog\Helper\Product\Flat\Indexer
29
+ */
30
+ private $ indexer ;
31
+
32
+ /**
33
+ * @param ResourceConnection $resource
34
+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
35
+ * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper
36
+ * @param \Magento\Catalog\Helper\Product\Flat\Indexer $indexer
37
+ */
38
+ public function __construct (
39
+ ResourceConnection $ resource ,
40
+ \Magento \Store \Model \StoreManagerInterface $ storeManager ,
41
+ \Magento \Catalog \Model \ResourceModel \Helper $ resourceHelper ,
42
+ \Magento \Catalog \Helper \Product \Flat \Indexer $ indexer = null
43
+ ) {
44
+ $ this ->indexer = $ indexer ?: \Magento \Framework \App \ObjectManager::getInstance ()
45
+ ->get (\Magento \Catalog \Helper \Product \Flat \Indexer::class);
46
+ parent ::__construct ($ resource , $ storeManager , $ resourceHelper );
47
+ }
48
+
22
49
/**
23
50
* Add suffix to table name to show it is old
24
51
*
@@ -92,6 +119,7 @@ protected function populateFlatTables(array $stores)
92
119
93
120
/**
94
121
* Create table and add attributes as fields for specified store.
122
+ *
95
123
* This routine assumes that DDL operations are allowed
96
124
*
97
125
* @param int $store
@@ -109,6 +137,7 @@ protected function createTable($store)
109
137
110
138
/**
111
139
* Create category flat tables and add attributes as fields.
140
+ *
112
141
* Tables are created only if DDL operations are allowed
113
142
*
114
143
* @param \Magento\Store\Model\Store[] $stores if empty, create tables for all stores of the application
@@ -182,7 +211,7 @@ public function reindexAll()
182
211
$ stores = $ this ->storeManager ->getStores ();
183
212
$ this ->populateFlatTables ($ stores );
184
213
$ this ->switchTables ($ stores );
185
-
214
+ $ this -> indexer -> deleteAbandonedStoreCategoryFlatTables ();
186
215
$ this ->allowTableChanges = true ;
187
216
188
217
return $ this ;
0 commit comments