@@ -160,7 +160,7 @@ protected function _syncData(array $processIds = [])
160
160
{
161
161
// for backward compatibility split data from old idx table on dimension tables
162
162
foreach ($ this ->dimensionCollectionFactory ->create () as $ dimensions ) {
163
- $ insertSelect = $ this ->_connection ->select ()->from (
163
+ $ insertSelect = $ this ->getConnection () ->select ()->from (
164
164
['ip_tmp ' => $ this ->_defaultIndexerResource ->getIdxTable ()]
165
165
);
166
166
@@ -174,7 +174,7 @@ protected function _syncData(array $processIds = [])
174
174
}
175
175
176
176
$ query = $ insertSelect ->insertFromSelect ($ this ->tableMaintainer ->getMainTable ($ dimensions ));
177
- $ this ->_connection ->query ($ query );
177
+ $ this ->getConnection () ->query ($ query );
178
178
}
179
179
return $ this ;
180
180
}
@@ -191,7 +191,7 @@ protected function _prepareWebsiteDateTable()
191
191
{
192
192
$ baseCurrency = $ this ->_config ->getValue (\Magento \Directory \Model \Currency::XML_PATH_CURRENCY_BASE );
193
193
194
- $ select = $ this ->_connection ->select ()->from (
194
+ $ select = $ this ->getConnection () ->select ()->from (
195
195
['cw ' => $ this ->_defaultIndexerResource ->getTable ('store_website ' )],
196
196
['website_id ' ]
197
197
)->join (
@@ -203,7 +203,7 @@ protected function _prepareWebsiteDateTable()
203
203
);
204
204
205
205
$ data = [];
206
- foreach ($ this ->_connection ->fetchAll ($ select ) as $ item ) {
206
+ foreach ($ this ->getConnection () ->fetchAll ($ select ) as $ item ) {
207
207
/** @var $website \Magento\Store\Model\Website */
208
208
$ website = $ this ->_storeManager ->getWebsite ($ item ['website_id ' ]);
209
209
@@ -237,7 +237,7 @@ protected function _prepareWebsiteDateTable()
237
237
$ this ->_emptyTable ($ table );
238
238
if ($ data ) {
239
239
foreach ($ data as $ row ) {
240
- $ this ->_connection ->insertOnDuplicate ($ table , $ row , array_keys ($ row ));
240
+ $ this ->getConnection () ->insertOnDuplicate ($ table , $ row , array_keys ($ row ));
241
241
}
242
242
}
243
243
@@ -325,19 +325,19 @@ protected function _getIndexer($productTypeId)
325
325
*/
326
326
protected function _insertFromTable ($ sourceTable , $ destTable , $ where = null )
327
327
{
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 );
331
331
if ($ where ) {
332
332
$ select ->where ($ where );
333
333
}
334
- $ query = $ this ->_connection ->insertFromSelect (
334
+ $ query = $ this ->getConnection () ->insertFromSelect (
335
335
$ select ,
336
336
$ destTable ,
337
337
$ targetColumns ,
338
338
\Magento \Framework \DB \Adapter \AdapterInterface::INSERT_ON_DUPLICATE
339
339
);
340
- $ this ->_connection ->query ($ query );
340
+ $ this ->getConnection () ->query ($ query );
341
341
}
342
342
343
343
/**
@@ -348,7 +348,7 @@ protected function _insertFromTable($sourceTable, $destTable, $where = null)
348
348
*/
349
349
protected function _emptyTable ($ table )
350
350
{
351
- $ this ->_connection ->delete ($ table );
351
+ $ this ->getConnection () ->delete ($ table );
352
352
}
353
353
354
354
/**
@@ -381,7 +381,7 @@ protected function _reindexRows($changedIds = [])
381
381
$ this ->tableMaintainer ->createMainTmpTable ($ dimensions );
382
382
$ temporaryTable = $ this ->tableMaintainer ->getMainTmpTable ($ dimensions );
383
383
$ this ->_emptyTable ($ temporaryTable );
384
- $ indexer ->executeByDimension ($ dimensions , \SplFixedArray::fromArray ($ entityIds , false ));
384
+ $ indexer ->executeByDimensions ($ dimensions , \SplFixedArray::fromArray ($ entityIds , false ));
385
385
// copy to index
386
386
$ this ->_insertFromTable (
387
387
$ temporaryTable ,
@@ -407,12 +407,12 @@ protected function _reindexRows($changedIds = [])
407
407
private function deleteIndexData (array $ entityIds )
408
408
{
409
409
foreach ($ this ->dimensionCollectionFactory ->create () as $ dimensions ) {
410
- $ select = $ this ->_connection ->select ()->from (
410
+ $ select = $ this ->getConnection () ->select ()->from (
411
411
['index_price ' => $ this ->tableMaintainer ->getMainTable ($ dimensions )],
412
412
null
413
413
)->where ('index_price.entity_id IN (?) ' , $ entityIds );
414
414
$ query = $ select ->deleteFromSelect ('index_price ' );
415
- $ this ->_connection ->query ($ query );
415
+ $ this ->getConnection () ->query ($ query );
416
416
}
417
417
}
418
418
@@ -430,7 +430,7 @@ private function deleteIndexData(array $entityIds)
430
430
protected function _copyRelationIndexData ($ parentIds , $ excludeIds = null )
431
431
{
432
432
$ linkField = $ this ->getProductIdFieldName ();
433
- $ select = $ this ->_connection ->select ()->from (
433
+ $ select = $ this ->getConnection () ->select ()->from (
434
434
$ this ->_defaultIndexerResource ->getTable ('catalog_product_relation ' ),
435
435
['child_id ' ]
436
436
)->join (
@@ -445,18 +445,18 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null)
445
445
$ select ->where ('child_id NOT IN(?) ' , $ excludeIds );
446
446
}
447
447
448
- $ children = $ this ->_connection ->fetchCol ($ select );
448
+ $ children = $ this ->getConnection () ->fetchCol ($ select );
449
449
450
450
if ($ children ) {
451
451
foreach ($ this ->dimensionCollectionFactory ->create () as $ dimensions ) {
452
- $ select = $ this ->_connection ->select ()->from (
452
+ $ select = $ this ->getConnection () ->select ()->from (
453
453
$ this ->getIndexTargetTableByDimension ($ dimensions )
454
454
)->where (
455
455
'entity_id IN(?) ' ,
456
456
$ children
457
457
);
458
458
$ query = $ select ->insertFromSelect ($ this ->_defaultIndexerResource ->getIdxTable (), [], false );
459
- $ this ->_connection ->query ($ query );
459
+ $ this ->getConnection () ->query ($ query );
460
460
}
461
461
}
462
462
@@ -502,8 +502,8 @@ protected function getIndexTargetTable()
502
502
protected function getProductIdFieldName ()
503
503
{
504
504
$ 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 ];
507
507
}
508
508
509
509
/**
@@ -514,14 +514,14 @@ protected function getProductIdFieldName()
514
514
*/
515
515
private function getProductsTypes (array $ changedIds = [])
516
516
{
517
- $ select = $ this ->_connection ->select ()->from (
517
+ $ select = $ this ->getConnection () ->select ()->from (
518
518
$ this ->_defaultIndexerResource ->getTable ('catalog_product_entity ' ),
519
519
['entity_id ' , 'type_id ' ]
520
520
);
521
521
if ($ changedIds ) {
522
522
$ select ->where ('entity_id IN (?) ' , $ changedIds );
523
523
}
524
- $ pairs = $ this ->_connection ->fetchPairs ($ select );
524
+ $ pairs = $ this ->getConnection () ->fetchPairs ($ select );
525
525
526
526
$ byType = [];
527
527
foreach ($ pairs as $ productId => $ productType ) {
@@ -540,7 +540,7 @@ private function getProductsTypes(array $changedIds = [])
540
540
*/
541
541
private function getParentProductsTypes (array $ productsIds )
542
542
{
543
- $ select = $ this ->_connection ->select ()->from (
543
+ $ select = $ this ->getConnection () ->select ()->from (
544
544
['l ' => $ this ->_defaultIndexerResource ->getTable ('catalog_product_relation ' )],
545
545
''
546
546
)->join (
@@ -551,7 +551,7 @@ private function getParentProductsTypes(array $productsIds)
551
551
'l.child_id IN(?) ' ,
552
552
$ productsIds
553
553
);
554
- $ pairs = $ this ->_connection ->fetchPairs ($ select );
554
+ $ pairs = $ this ->getConnection () ->fetchPairs ($ select );
555
555
556
556
$ byType = [];
557
557
foreach ($ pairs as $ productId => $ productType ) {
@@ -560,4 +560,14 @@ private function getParentProductsTypes(array $productsIds)
560
560
561
561
return $ byType ;
562
562
}
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
+ }
563
573
}
0 commit comments