@@ -87,13 +87,29 @@ public function __construct(
87
87
$ this ->activeTableSwitcher = $ activeTableSwitcher ?: $ objectManager ->get (ActiveTableSwitcher::class);
88
88
}
89
89
90
+ /**
91
+ *
92
+ * Clear the table we'll be writing de-normalized data into
93
+ * to prevent archived data getting in the way of actual data.
94
+ *
95
+ * @return void
96
+ */
97
+ private function clearCurrentTable ()
98
+ {
99
+ $ this ->connection ->delete (
100
+ $ this ->activeTableSwitcher
101
+ ->getAdditionalTableName ($ this ->getMainTable ())
102
+ );
103
+ }
104
+
90
105
/**
91
106
* Refresh entities index
92
107
*
93
108
* @return $this
94
109
*/
95
110
public function execute ()
96
111
{
112
+ $ this ->clearCurrentTable ();
97
113
$ this ->reindex ();
98
114
$ this ->activeTableSwitcher ->switchTable ($ this ->connection , [$ this ->getMainTable ()]);
99
115
return $ this ;
@@ -103,6 +119,9 @@ public function execute()
103
119
* Return select for remove unnecessary data
104
120
*
105
121
* @return \Magento\Framework\DB\Select
122
+ *
123
+ * @deprecated Not used anymore.
124
+ * @see clearCurrentTable()
106
125
*/
107
126
protected function getSelectUnnecessaryData ()
108
127
{
@@ -127,12 +146,14 @@ protected function getSelectUnnecessaryData()
127
146
* Remove unnecessary data
128
147
*
129
148
* @return void
149
+ *
150
+ * @deprecated Not used anymore.
151
+ * @see clearCurrentTable()
130
152
*/
131
153
protected function removeUnnecessaryData ()
132
154
{
133
- $ this ->connection ->query (
134
- $ this ->connection ->deleteFromSelect ($ this ->getSelectUnnecessaryData (), $ this ->getMainTable ())
135
- );
155
+ //Called for backward compatibility.
156
+ $ this ->getSelectUnnecessaryData ();
136
157
}
137
158
138
159
/**
@@ -233,6 +254,7 @@ private function reindexCategoriesBySelect(\Magento\Framework\DB\Select $basicSe
233
254
)
234
255
);
235
256
$ this ->publishData ();
257
+ //Called for backward compatibility.
236
258
$ this ->removeUnnecessaryData ();
237
259
}
238
260
}
0 commit comments