23 use \Magento\Framework\Search\Request\IndexScopeResolverInterface;
45 private $customerSession;
50 private $dataProvider;
55 private $intervalFactory;
65 private $storeManager;
70 private $priceTableResolver;
75 private $dimensionFactory;
91 MysqlDataProviderInterface $dataProvider,
98 $this->connection =
$resource->getConnection();
99 $this->range = $range;
100 $this->customerSession = $customerSession;
101 $this->dataProvider = $dataProvider;
102 $this->intervalFactory = $intervalFactory;
105 IndexScopeResolverInterface::class
115 return $this->range->getPriceRange();
124 'count' =>
'count(main_table.entity_id)',
125 'max' =>
'MAX(min_price)',
126 'min' =>
'MIN(min_price)',
127 'std' =>
'STDDEV_SAMP(min_price)',
131 $websiteId = $this->storeManager->getStore()->getWebsiteId();
132 $customerGroupId = $this->customerSession->getCustomerGroupId();
134 $tableName = $this->priceTableResolver->resolve(
135 'catalog_product_index_price',
137 $this->dimensionFactory->create(
141 $this->dimensionFactory->create(
143 (
string)$customerGroupId
148 $table = $entityStorage->getSource();
150 ->where(
'main_table.entity_id in (select entity_id from ' .
$table->getName() .
')')
151 ->columns($aggregation);
153 $select->where(
'customer_group_id = ?', $customerGroupId);
156 return $this->connection->fetchRow(
$select);
165 \
Magento\Framework\Search\Dynamic\EntityStorage $entityStorage
167 $select = $this->dataProvider->getDataSet($bucket, $dimensions, $entityStorage->getSource());
169 return $this->intervalFactory->create([
'select' =>
$select]);
179 \
Magento\Framework\Search\Dynamic\EntityStorage $entityStorage
181 $select = $this->dataProvider->getDataSet($bucket, $dimensions, $entityStorage->getSource());
184 $rangeExpr = new \Zend_Db_Expr(
185 $this->connection->getIfNullSql(
186 $this->connection->quoteInto(
'FLOOR(' . $column[1] .
' / ? ) + 1', $range),
192 ->columns([
'range' => $rangeExpr])
193 ->columns([
'metrix' =>
'COUNT(*)'])
207 if (!empty($dbRanges)) {
208 $lastIndex = array_keys($dbRanges);
209 $lastIndex = $lastIndex[count($lastIndex) - 1];
216 'from' => $fromPrice,
229 private function getSelect()
231 return $this->connection->select();
prepareData($range, array $dbRanges)
getAggregation(BucketInterface $bucket, array $dimensions, $range, \Magento\Framework\Search\Dynamic\EntityStorage $entityStorage)
getAggregations(EntityStorage $entityStorage)
__construct(ResourceConnection $resource, Range $range, Session $customerSession, MysqlDataProviderInterface $dataProvider, IntervalFactory $intervalFactory, StoreManager $storeManager=null, IndexScopeResolverInterface $priceTableResolver=null, DimensionFactory $dimensionFactory=null)
getInterval(BucketInterface $bucket, array $dimensions, \Magento\Framework\Search\Dynamic\EntityStorage $entityStorage)