Ejemplo n.º 1
0
 /**
  * Retrieve subordinate coupons
  *
  * @return \Magento\SalesRule\Model\Coupon[]
  */
 public function getCoupons()
 {
     if ($this->_coupons === null) {
         $this->_couponCollection->addRuleToFilter($this);
         $this->_coupons = $this->_couponCollection->getItems();
     }
     return $this->_coupons;
 }
 /**
  * Helper function that adds a FilterGroup to the collection.
  *
  * @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
  * @param Collection $collection
  * @return void
  */
 protected function addFilterGroupToCollection(\Magento\Framework\Api\Search\FilterGroup $filterGroup, Collection $collection)
 {
     $fields = [];
     $conditions = [];
     foreach ($filterGroup->getFilters() as $filter) {
         $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
         $fields[] = $filter->getField();
         $conditions[] = [$condition => $filter->getValue()];
     }
     if ($fields) {
         $collection->addFieldToFilter($fields, $conditions);
     }
 }