예제 #1
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     parent::_prepareForm();
     /** @var \Magento\Framework\Data\Form\Element\Fieldset $fieldset */
     $fieldset = $this->getForm()->getElement('base_fieldset');
     if (is_object($fieldset) && $fieldset instanceof \Magento\Framework\Data\Form\Element\Fieldset) {
         $fieldset->addField('price_rule_type', 'select', ['name' => 'price_rule_type', 'options' => [__('Any'), __('Specified')], 'label' => __('Cart Price Rule')]);
         $rulesList = $this->_reportRule->create()->getUniqRulesNamesList();
         $rulesListOptions = [];
         foreach ($rulesList as $key => $ruleName) {
             $rulesListOptions[] = ['label' => $ruleName, 'value' => $key, 'title' => $ruleName];
         }
         $fieldset->addField('rules_list', 'multiselect', ['name' => 'rules_list', 'values' => $rulesListOptions, 'display' => 'none'], 'price_rule_type');
         $this->_renderDependentElement = true;
     }
     return $this;
 }
예제 #2
0
 /**
  * Apply filtering by rules ids
  *
  * @return $this
  */
 protected function _applyRulesFilter()
 {
     if (empty($this->_rulesIdsFilter) || !is_array($this->_rulesIdsFilter)) {
         return $this;
     }
     $rulesList = $this->_ruleFactory->create()->getUniqRulesNamesList();
     $rulesFilterSqlParts = [];
     foreach ($this->_rulesIdsFilter as $ruleId) {
         if (!isset($rulesList[$ruleId])) {
             continue;
         }
         $ruleName = $rulesList[$ruleId];
         $rulesFilterSqlParts[] = $this->getConnection()->quoteInto('rule_name = ?', $ruleName);
     }
     if (!empty($rulesFilterSqlParts)) {
         $this->getSelect()->where(implode(' OR ', $rulesFilterSqlParts));
     }
     return $this;
 }