Create conditions for coupon rule in Magento 2

I’m trying to create conditions in the coupon rules, but when creating the conditions they are not aggregated correctly Im doing: $rule = $this->couponRule; $cond[‘conditions’][‘1’][‘type’]= ‘Magento\SalesRule\Model\Rule\Condition\Combine’; $cond[‘conditions’][‘1’][‘new_child’]= ”; $cond[‘conditions’][‘1’][‘aggregator’]= ‘all’; $cond[‘conditions’][‘1’][‘value’]= 1; $cond[‘conditions’][‘1–1’][‘type’]= ‘Magento\SalesRule\Model\Rule\Condition\Product\Found’; $cond[‘conditions’][‘1–1’][‘new_child’]= ”; $cond[‘conditions’][‘1–1’][‘value’]= 1; $cond[‘conditions’][‘1–1’][‘aggregator’]= ‘all’; $cond[‘conditions’][‘1–1–1’][‘type’]= ‘Magento\SalesRule\Model\Rule\Condition\Product’; $cond[‘conditions’][‘1–1–1’][‘attribute’]= ‘category_ids’; $cond[‘conditions’][‘1–1–1’][‘attribute_scope’]= ‘parent’; $cond[‘conditions’][‘1–1–1’][‘operator’]= ‘!{}’; $cond[‘conditions’][‘1–1–1’][‘value’]= 10; try { $rule->setName(‘Cupom Dinâmico’) ->setDescription(‘Criado…

How to define default values in case of no results of a query? [closed]

I use this query on custom content entities to define default values for a form: $database = \Drupal::database(); $query = $database->select(‘member’, ‘am’); $query->leftJoin(‘person’, ‘ap’, ‘ap.member_id = am.id’); $query->fields(‘ap’, [‘id’, ‘lastname’, ‘firstname’, ’email’, ‘cellphone’, ‘iscontact’]) ->fields(‘am’, [‘id’, ‘designation’, ‘addresssupplement’, ‘street’, ‘postalcode’, ‘city’, ‘contact_id’, ‘telephone’, ‘status’]) ->condition(‘am.contact_id’, $iCurrentUserId, ‘=’) ->orderBy(‘iscontact’, ‘DESC’); $results = $query->execute()->fetchAll(); The query may…

Create conditions for coupon rule in Magento 2

I’m trying to create conditions in the coupon rules, but when creating the conditions they are not aggregated correctly Im doing: $rule = $this->couponRule; $cond[‘conditions’][‘1’][‘type’]= ‘Magento\SalesRule\Model\Rule\Condition\Combine’; $cond[‘conditions’][‘1’][‘new_child’]= ”; $cond[‘conditions’][‘1’][‘aggregator’]= ‘all’; $cond[‘conditions’][‘1’][‘value’]= 1; $cond[‘conditions’][‘1–1’][‘type’]= ‘Magento\SalesRule\Model\Rule\Condition\Product\Found’; $cond[‘conditions’][‘1–1’][‘new_child’]= ”; $cond[‘conditions’][‘1–1’][‘value’]= 1; $cond[‘conditions’][‘1–1’][‘aggregator’]= ‘all’; $cond[‘conditions’][‘1–1–1’][‘type’]= ‘Magento\SalesRule\Model\Rule\Condition\Product’; $cond[‘conditions’][‘1–1–1’][‘attribute’]= ‘category_ids’; $cond[‘conditions’][‘1–1–1’][‘attribute_scope’]= ‘parent’; $cond[‘conditions’][‘1–1–1’][‘operator’]= ‘!{}’; $cond[‘conditions’][‘1–1–1’][‘value’]= 10; try { $rule->setName(‘Cupom Dinâmico’) ->setDescription(‘Criado…