Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CompositeProductRowSizeEstimator.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
12 
17 {
22 
26  private $websiteManagement;
27 
31  private $collectionFactory;
32 
36  private $compositeProductRelationsCalculator;
37 
43  public function __construct(
44  WebsiteManagementInterface $websiteManagement,
45  CollectionFactory $collectionFactory,
46  CompositeProductRelationsCalculator $compositeProductRelationsCalculator
47  ) {
48  $this->websiteManagement = $websiteManagement;
49  $this->collectionFactory = $collectionFactory;
50  $this->compositeProductRelationsCalculator = $compositeProductRelationsCalculator;
51  }
52 
58  public function estimateRowSize()
59  {
60  $websitesCount = $this->websiteManagement->getCount();
61  $customerGroupCount = $this->collectionFactory->create()->getSize();
62  $maxRelatedProductCount = $this->compositeProductRelationsCalculator->getMaxRelationsCount();
63 
72  return ceil($maxRelatedProductCount * $websitesCount * $customerGroupCount * self::MEMORY_SIZE_FOR_ONE_ROW);
73  }
74 }
__construct(WebsiteManagementInterface $websiteManagement, CollectionFactory $collectionFactory, CompositeProductRelationsCalculator $compositeProductRelationsCalculator)