@@ -160,7 +160,7 @@ protected function _syncData(array $processIds = [])
160160    {
161161        // for backward compatibility split data from old idx table on dimension tables 
162162        foreach  ($ this  ->dimensionCollectionFactory ->create () as  $ dimensions ) {
163-             $ insertSelect  = $ this  ->_connection ->select ()->from (
163+             $ insertSelect  = $ this  ->getConnection () ->select ()->from (
164164                ['ip_tmp '  => $ this  ->_defaultIndexerResource ->getIdxTable ()]
165165            );
166166
@@ -174,7 +174,7 @@ protected function _syncData(array $processIds = [])
174174            }
175175
176176            $ query  = $ insertSelect ->insertFromSelect ($ this  ->tableMaintainer ->getMainTable ($ dimensions ));
177-             $ this  ->_connection ->query ($ query );
177+             $ this  ->getConnection () ->query ($ query );
178178        }
179179        return  $ this  ;
180180    }
@@ -191,7 +191,7 @@ protected function _prepareWebsiteDateTable()
191191    {
192192        $ baseCurrency  = $ this  ->_config ->getValue (\Magento \Directory \Model \Currency::XML_PATH_CURRENCY_BASE );
193193
194-         $ select  = $ this  ->_connection ->select ()->from (
194+         $ select  = $ this  ->getConnection () ->select ()->from (
195195            ['cw '  => $ this  ->_defaultIndexerResource ->getTable ('store_website ' )],
196196            ['website_id ' ]
197197        )->join (
@@ -203,7 +203,7 @@ protected function _prepareWebsiteDateTable()
203203        );
204204
205205        $ data  = [];
206-         foreach  ($ this  ->_connection ->fetchAll ($ select ) as  $ item ) {
206+         foreach  ($ this  ->getConnection () ->fetchAll ($ select ) as  $ item ) {
207207            /** @var $website \Magento\Store\Model\Website */ 
208208            $ website  = $ this  ->_storeManager ->getWebsite ($ item ['website_id ' ]);
209209
@@ -237,7 +237,7 @@ protected function _prepareWebsiteDateTable()
237237        $ this  ->_emptyTable ($ table );
238238        if  ($ data ) {
239239            foreach  ($ data  as  $ row ) {
240-                 $ this  ->_connection ->insertOnDuplicate ($ table , $ row , array_keys ($ row ));
240+                 $ this  ->getConnection () ->insertOnDuplicate ($ table , $ row , array_keys ($ row ));
241241            }
242242        }
243243
@@ -325,19 +325,19 @@ protected function _getIndexer($productTypeId)
325325     */ 
326326    protected  function  _insertFromTable ($ sourceTable , $ destTable , $ where  = null )
327327    {
328-         $ sourceColumns  = array_keys ($ this  ->_connection ->describeTable ($ sourceTable ));
329-         $ targetColumns  = array_keys ($ this  ->_connection ->describeTable ($ destTable ));
330-         $ select  = $ this  ->_connection ->select ()->from ($ sourceTable , $ sourceColumns );
328+         $ sourceColumns  = array_keys ($ this  ->getConnection () ->describeTable ($ sourceTable ));
329+         $ targetColumns  = array_keys ($ this  ->getConnection () ->describeTable ($ destTable ));
330+         $ select  = $ this  ->getConnection () ->select ()->from ($ sourceTable , $ sourceColumns );
331331        if  ($ where ) {
332332            $ select ->where ($ where );
333333        }
334-         $ query  = $ this  ->_connection ->insertFromSelect (
334+         $ query  = $ this  ->getConnection () ->insertFromSelect (
335335            $ select ,
336336            $ destTable ,
337337            $ targetColumns ,
338338            \Magento \Framework \DB \Adapter \AdapterInterface::INSERT_ON_DUPLICATE 
339339        );
340-         $ this  ->_connection ->query ($ query );
340+         $ this  ->getConnection () ->query ($ query );
341341    }
342342
343343    /** 
@@ -348,7 +348,7 @@ protected function _insertFromTable($sourceTable, $destTable, $where = null)
348348     */ 
349349    protected  function  _emptyTable ($ table )
350350    {
351-         $ this  ->_connection ->delete ($ table );
351+         $ this  ->getConnection () ->delete ($ table );
352352    }
353353
354354    /** 
@@ -381,7 +381,7 @@ protected function _reindexRows($changedIds = [])
381381                    $ this  ->tableMaintainer ->createMainTmpTable ($ dimensions );
382382                    $ temporaryTable  = $ this  ->tableMaintainer ->getMainTmpTable ($ dimensions );
383383                    $ this  ->_emptyTable ($ temporaryTable );
384-                     $ indexer ->executeByDimension ($ dimensions , \SplFixedArray::fromArray ($ entityIds , false ));
384+                     $ indexer ->executeByDimensions ($ dimensions , \SplFixedArray::fromArray ($ entityIds , false ));
385385                    // copy to index 
386386                    $ this  ->_insertFromTable (
387387                        $ temporaryTable ,
@@ -407,12 +407,12 @@ protected function _reindexRows($changedIds = [])
407407    private  function  deleteIndexData (array  $ entityIds )
408408    {
409409        foreach  ($ this  ->dimensionCollectionFactory ->create () as  $ dimensions ) {
410-             $ select  = $ this  ->_connection ->select ()->from (
410+             $ select  = $ this  ->getConnection () ->select ()->from (
411411                ['index_price '  => $ this  ->tableMaintainer ->getMainTable ($ dimensions )],
412412                null 
413413            )->where ('index_price.entity_id IN (?) ' , $ entityIds );
414414            $ query  = $ select ->deleteFromSelect ('index_price ' );
415-             $ this  ->_connection ->query ($ query );
415+             $ this  ->getConnection () ->query ($ query );
416416        }
417417    }
418418
@@ -430,7 +430,7 @@ private function deleteIndexData(array $entityIds)
430430    protected  function  _copyRelationIndexData ($ parentIds , $ excludeIds  = null )
431431    {
432432        $ linkField  = $ this  ->getProductIdFieldName ();
433-         $ select  = $ this  ->_connection ->select ()->from (
433+         $ select  = $ this  ->getConnection () ->select ()->from (
434434            $ this  ->_defaultIndexerResource ->getTable ('catalog_product_relation ' ),
435435            ['child_id ' ]
436436        )->join (
@@ -445,18 +445,18 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null)
445445            $ select ->where ('child_id NOT IN(?) ' , $ excludeIds );
446446        }
447447
448-         $ children  = $ this  ->_connection ->fetchCol ($ select );
448+         $ children  = $ this  ->getConnection () ->fetchCol ($ select );
449449
450450        if  ($ children ) {
451451            foreach  ($ this  ->dimensionCollectionFactory ->create () as  $ dimensions ) {
452-                 $ select  = $ this  ->_connection ->select ()->from (
452+                 $ select  = $ this  ->getConnection () ->select ()->from (
453453                    $ this  ->getIndexTargetTableByDimension ($ dimensions )
454454                )->where (
455455                    'entity_id IN(?) ' ,
456456                    $ children
457457                );
458458                $ query  = $ select ->insertFromSelect ($ this  ->_defaultIndexerResource ->getIdxTable (), [], false );
459-                 $ this  ->_connection ->query ($ query );
459+                 $ this  ->getConnection () ->query ($ query );
460460            }
461461        }
462462
@@ -502,8 +502,8 @@ protected function getIndexTargetTable()
502502    protected  function  getProductIdFieldName ()
503503    {
504504        $ table  = $ this  ->_defaultIndexerResource ->getTable ('catalog_product_entity ' );
505-         $ indexList  = $ this  ->_connection ->getIndexList ($ table );
506-         return  $ indexList [$ this  ->_connection ->getPrimaryKeyName ($ table )]['COLUMNS_LIST ' ][0 ];
505+         $ indexList  = $ this  ->getConnection () ->getIndexList ($ table );
506+         return  $ indexList [$ this  ->getConnection () ->getPrimaryKeyName ($ table )]['COLUMNS_LIST ' ][0 ];
507507    }
508508
509509    /** 
@@ -514,14 +514,14 @@ protected function getProductIdFieldName()
514514     */ 
515515    private  function  getProductsTypes (array  $ changedIds  = [])
516516    {
517-         $ select  = $ this  ->_connection ->select ()->from (
517+         $ select  = $ this  ->getConnection () ->select ()->from (
518518            $ this  ->_defaultIndexerResource ->getTable ('catalog_product_entity ' ),
519519            ['entity_id ' , 'type_id ' ]
520520        );
521521        if  ($ changedIds ) {
522522            $ select ->where ('entity_id IN (?) ' , $ changedIds );
523523        }
524-         $ pairs  = $ this  ->_connection ->fetchPairs ($ select );
524+         $ pairs  = $ this  ->getConnection () ->fetchPairs ($ select );
525525
526526        $ byType  = [];
527527        foreach  ($ pairs  as  $ productId  => $ productType ) {
@@ -540,7 +540,7 @@ private function getProductsTypes(array $changedIds = [])
540540     */ 
541541    private  function  getParentProductsTypes (array  $ productsIds )
542542    {
543-         $ select  = $ this  ->_connection ->select ()->from (
543+         $ select  = $ this  ->getConnection () ->select ()->from (
544544            ['l '  => $ this  ->_defaultIndexerResource ->getTable ('catalog_product_relation ' )],
545545            '' 
546546        )->join (
@@ -551,7 +551,7 @@ private function getParentProductsTypes(array $productsIds)
551551            'l.child_id IN(?) ' ,
552552            $ productsIds
553553        );
554-         $ pairs  = $ this  ->_connection ->fetchPairs ($ select );
554+         $ pairs  = $ this  ->getConnection () ->fetchPairs ($ select );
555555
556556        $ byType  = [];
557557        foreach  ($ pairs  as  $ productId  => $ productType ) {
@@ -560,4 +560,14 @@ private function getParentProductsTypes(array $productsIds)
560560
561561        return  $ byType ;
562562    }
563+ 
564+     /** 
565+      * Get connection 
566+      * 
567+      * @return \Magento\Framework\DB\Adapter\AdapterInterface 
568+      */ 
569+     private  function  getConnection ()
570+     {
571+         return  $ this  ->_defaultIndexerResource ->getConnection ();
572+     }
563573}
0 commit comments