@@ -52,7 +52,6 @@ class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
5252 * @param \Magento\Framework\Indexer\BatchSizeManagementInterface|null $batchSizeManagement
5353 * @param \Magento\Framework\Indexer\BatchProviderInterface|null $batchProvider
5454 * @param \Magento\Framework\EntityManager\MetadataPool|null $metadataPool
55- * @param \Magento\Indexer\Model\Indexer\StateFactory|null $stateFactory
5655 * @param int|null $batchRowsCount
5756 * @param ActiveTableSwitcher|null $activeTableSwitcher
5857 */
@@ -87,13 +86,28 @@ public function __construct(
8786 $ this ->activeTableSwitcher = $ activeTableSwitcher ?: $ objectManager ->get (ActiveTableSwitcher::class);
8887 }
8988
89+ /**
90+ * Clear the table we'll be writing de-normalized data into
91+ * to prevent archived data getting in the way of actual data.
92+ *
93+ * @return void
94+ */
95+ private function clearCurrentTable ()
96+ {
97+ $ this ->connection ->delete (
98+ $ this ->activeTableSwitcher
99+ ->getAdditionalTableName ($ this ->getMainTable ())
100+ );
101+ }
102+
90103 /**
91104 * Refresh entities index
92105 *
93106 * @return $this
94107 */
95108 public function execute ()
96109 {
110+ $ this ->clearCurrentTable ();
97111 $ this ->reindex ();
98112 $ this ->activeTableSwitcher ->switchTable ($ this ->connection , [$ this ->getMainTable ()]);
99113 return $ this ;
@@ -103,6 +117,7 @@ public function execute()
103117 * Return select for remove unnecessary data
104118 *
105119 * @return \Magento\Framework\DB\Select
120+ * @deprecated 102.0.1 Not needed anymore.
106121 */
107122 protected function getSelectUnnecessaryData ()
108123 {
@@ -127,12 +142,15 @@ protected function getSelectUnnecessaryData()
127142 * Remove unnecessary data
128143 *
129144 * @return void
145+ *
146+ * @deprecated 102.0.1 Not needed anymore.
130147 */
131148 protected function removeUnnecessaryData ()
132149 {
133- $ this ->connection ->query (
134- $ this ->connection ->deleteFromSelect ($ this ->getSelectUnnecessaryData (), $ this ->getMainTable ())
135- );
150+ //Called for backwards compatibility.
151+ $ this ->getSelectUnnecessaryData ();
152+ //This method is useless,
153+ //left it here just in case somebody's using it in child classes.
136154 }
137155
138156 /**
0 commit comments