Пример #1
0
 /**
  * retrieve rating options
  *
  * @return array
  */
 public function getOptions()
 {
     $options = $this->getData('options');
     if ($options) {
         return $options;
     } elseif ($this->getId()) {
         return $this->_ratingCollectionF->create()->addRatingFilter($this->getId())->setPositionOrder()->load()->getItems();
     }
     return [];
 }
Пример #2
0
 /**
  * Add options to ratings in collection
  *
  * @return $this
  */
 public function addOptionToItems()
 {
     $arrRatingId = $this->getColumnValues('rating_id');
     if (!empty($arrRatingId)) {
         /** @var \Magento\Review\Model\ResourceModel\Rating\Option\Collection $collection */
         $collection = $this->_ratingCollectionF->create()->addRatingFilter($arrRatingId)->setPositionOrder()->load();
         foreach ($this as $rating) {
             $rating->setOptions($collection->getItemsByColumnValue('rating_id', $rating->getId()));
         }
     }
     return $this;
 }
Пример #3
0
 /**
  * Add rating options
  *
  * @return $this
  */
 public function addRatingOptions()
 {
     if (!$this->getSize()) {
         return $this;
     }
     foreach ($this->getItems() as $item) {
         /** @var \Magento\Review\Model\ResourceModel\Rating\Option\Collection $options */
         $options = $this->_ratingCollectionF->create();
         $options->addRatingFilter($item->getRatingId())->load();
         if ($item->getRatingId()) {
             $item->setRatingOptions($options);
         } else {
             return $this;
         }
     }
     return $this;
 }