48 \
Magento\Framework\Event\ManagerInterface $eventManager,
55 $this->_ratingCollectionF = $ratingCollectionF;
86 'main_table.entity_id=' . $this->
getTable(
'rating_entity') .
'.entity_id',
114 $this->
setOrder(
'main_table.position', $dir);
126 if ($this->_storeManager->isSingleStoreMode()) {
136 if (!$this->_isStoreJoined) {
140 [
'store' => $this->
getTable(
'rating_store')],
141 'main_table.rating_id = store.rating_id',
144 $this->_isStoreJoined =
true;
157 public function addOptionToItems()
161 if (!empty($arrRatingId)) {
163 $collection = $this->_ratingCollectionF->create()->addRatingFilter(
165 )->setPositionOrder()->load();
185 if (
count($arrRatingId) == 0) {
191 $inCond =
$connection->prepareSqlCondition(
'rating_option_vote.rating_id', [
'in' => $arrRatingId]);
192 $sumCond = new \Zend_Db_Expr(
"SUM(rating_option_vote.{$connection->quoteIdentifier('percent')})");
193 $countCond = new \Zend_Db_Expr(
'COUNT(*)');
195 [
'rating_option_vote' => $this->
getTable(
'rating_option_vote')],
196 [
'rating_id' =>
'rating_option_vote.rating_id',
'sum' => $sumCond,
'count' => $countCond]
198 [
'review_store' => $this->
getTable(
'review_store')],
199 'rating_option_vote.review_id=review_store.review_id AND review_store.store_id = :store_id',
202 if (!$this->_storeManager->isSingleStoreMode()) {
204 [
'rst' => $this->
getTable(
'rating_store')],
205 'rst.rating_id = rating_option_vote.rating_id AND rst.store_id = :rst_store_id',
210 [
'review' => $this->
getTable(
'review')],
211 'review_store.review_id=review.review_id AND review.status_id=1',
216 'rating_option_vote.entity_pk_value=:pk_value' 218 'rating_option_vote.rating_id' 220 $bind = [
':store_id' => (int)
$storeId,
':pk_value' => $entityPkValue];
221 if (!$this->_storeManager->isSingleStoreMode()) {
222 $bind[
':rst_store_id'] = (int)
$storeId;
245 $ratingCodeCond =
$connection->getIfNullSql(
'title.value',
'main_table.rating_code');
247 [
'title' => $this->
getTable(
'rating_title')],
248 $connection->quoteInto(
'main_table.rating_id=title.rating_id AND title.store_id = ?', (
int)
$storeId),
249 [
'rating_code' => $ratingCodeCond]
261 if (!$this->_storeManager->isSingleStoreMode()) {
262 if (!$this->_isCollectionLoaded) {
263 $this->_addStoreDataFlag =
true;
264 }
elseif (!$this->_addStoreDataFlag) {
279 public function load($printQuery =
false, $logQuery =
false)
284 $this->_eventManager->dispatch(
'rating_rating_collection_load_before', [
'collection' => $this]);
285 parent::load($printQuery, $logQuery);
286 if ($this->_addStoreDataFlag) {
300 foreach ($this as
$item) {
301 $ratingIds[] =
$item->getId();
302 $item->setStores([]);
309 $inCondition =
$connection->prepareSqlCondition(
'rating_id', [
'in' => $ratingIds]);
311 $this->_select =
$connection->select()->from($this->
getTable(
'rating_store'))->where($inCondition);
317 $item->setStores(array_merge(
$item->getStores(), [
$row[
'store_id']]));
331 $this->
getSelect()->where(
'main_table.is_active=?', $isActive);
elseif(isset( $params[ 'redirect_parent']))
__construct(\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Review\Model\ResourceModel\Rating\Option\CollectionFactory $ratingCollectionF, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource=null)
addFilter($field, $value, $type='and')
setActiveFilter($isActive=true)
addEntitySummaryToItem($entityPkValue, $storeId)
load($printQuery=false, $logQuery=false)
setOrder($field, $direction=self::SORT_ORDER_DESC)
_init($model, $resourceModel)
addRatingPerStoreName($storeId)
setPositionOrder($dir='ASC')
getColumnValues($colName)