Example #1
0
 /**
  * Add FilterGroup to the given quote collection.
  *
  * @param FilterGroup $filterGroup
  * @param QuoteCollection $collection
  * @return void
  * @throws InputException
  */
 protected function addFilterGroupToCollection(FilterGroup $filterGroup, QuoteCollection $collection)
 {
     $fields = [];
     $conditions = [];
     foreach ($filterGroup->getFilters() as $filter) {
         $fields[] = $this->getQuoteSearchField($filter->getField());
         $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
         $conditions[] = array($condition => $filter->getValue());
     }
     if ($fields) {
         $collection->addFieldToFilter($fields, $conditions);
     }
 }
Example #2
0
 /**
  * Helper function that adds a FilterGroup to the collection.
  *
  * @param \Magento\Framework\Service\V1\Data\Search\FilterGroup  $filterGroup
  * @param \Magento\Eav\Model\Resource\Entity\Attribute\Collection $collection
  * @return void
  * @throws \Magento\Framework\Exception\InputException
  */
 private function addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)
 {
     foreach ($filterGroup->getFilters() as $filter) {
         $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
         $collection->addFieldToFilter($this->translateField($filter->getField()), [$condition => $filter->getValue()]);
     }
 }
Example #3
0
 /**
  * Helper function that adds a FilterGroup to the collection.
  *
  * @param FilterGroup $filterGroup
  * @param Collection $collection
  * @return void
  * @throws \Magento\Framework\Exception\InputException
  */
 protected function addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)
 {
     $fields = [];
     $conditions = [];
     foreach ($filterGroup->getFilters() as $filter) {
         $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
         $field = $this->translateField($filter->getField());
         $fields[] = $field;
         $conditions[] = [$condition => $filter->getValue()];
         switch ($field) {
             case 'rate.tax_calculation_rate_id':
                 $collection->joinCalculationData('rate');
                 break;
             case 'ctc.customer_tax_class_id':
                 $collection->joinCalculationData('ctc');
                 break;
             case 'ptc.product_tax_class_id':
                 $collection->joinCalculationData('ptc');
                 break;
         }
     }
     if ($fields) {
         $collection->addFieldToFilter($fields, $conditions);
     }
 }
Example #4
0
 /**
  * Helper function that adds a FilterGroup to the collection.
  *
  * @param FilterGroup $filterGroup
  * @param Collection $collection
  * @return void
  * @throws \Magento\Framework\Exception\InputException
  */
 protected function addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)
 {
     $fields = [];
     foreach ($filterGroup->getFilters() as $filter) {
         $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
         $field = $this->translateField($filter->getField());
         $fields[] = array('attribute' => $field, $condition => $filter->getValue());
     }
     if ($fields) {
         $collection->addFieldToFilter($fields);
     }
 }
 /**
  * Helper function that adds a FilterGroup to the collection.
  *
  * TODO: This method duplicates functionality of search methods in other services and should be refactored.
  *
  * @param FilterGroup $filterGroup
  * @param TaxClassCollection $collection
  * @return void
  */
 protected function addFilterGroupToCollection(FilterGroup $filterGroup, TaxClassCollection $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);
     }
 }