Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DecimalRowSizeEstimator.php
Go to the documentation of this file.
1 <?php
8 
13 
24 {
28  private $indexerResource;
29 
33  private $storeManagement;
34 
38  private $metadataPool;
39 
45  public function __construct(
46  StoreManagementInterface $storeManagement,
47  Decimal $indexerResource,
48  MetadataPool $metadataPool
49  ) {
50  $this->storeManagement = $storeManagement;
51  $this->indexerResource = $indexerResource;
52  $this->metadataPool = $metadataPool;
53  }
54 
58  public function estimateRowSize()
59  {
60  $connection = $this->indexerResource->getConnection();
61  $entityIdField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
62 
63  $valueSelect = $connection->select();
64  $valueSelect->from(
65  ['value_table' => $this->indexerResource->getTable('catalog_product_entity_decimal')],
66  ['count' => new \Zend_Db_Expr('count(value_table.value_id)')]
67  );
68  $valueSelect->group([$entityIdField, 'store_id']);
69 
70  $maxSelect = $connection->select();
71  $maxSelect->from(
72  ['max_value' => $valueSelect],
73  ['count' => new \Zend_Db_Expr('MAX(count)')]
74  );
75  $maxRowsPerStore = $connection->fetchOne($maxSelect);
76 
77  return ceil($maxRowsPerStore * $this->storeManagement->getCount() * 500);
78  }
79 }
__construct(StoreManagementInterface $storeManagement, Decimal $indexerResource, MetadataPool $metadataPool)
$connection
Definition: bulk.php:13