Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CompositeProductRelationsCalculator.php
Go to the documentation of this file.
1 <?php
8 
13 {
17  public function __construct(DefaultPrice $indexerResource)
18  {
19  $this->indexerResource = $indexerResource;
20  }
21 
27  public function getMaxRelationsCount()
28  {
29  $connection = $this->indexerResource->getConnection();
30  $relationSelect = $connection->select();
31  $relationSelect->from(
32  ['relation' => $this->indexerResource->getTable('catalog_product_relation')],
33  ['count' => new \Zend_Db_Expr('count(relation.child_id)')]
34  );
35  $relationSelect->group('parent_id');
36 
37  $maxSelect = $connection->select();
38  $maxSelect->from(
39  ['max_value' => $relationSelect],
40  ['count' => new \Zend_Db_Expr('MAX(count)')]
41  );
42  return $connection->fetchOne($maxSelect);
43  }
44 }
$connection
Definition: bulk.php:13