/** * Validate * * @param \Magento\Framework\Object $object Quote * @return bool */ public function validate(\Magento\Framework\Object $object) { if (!$this->getConditions()) { return false; } $attr = $this->getAttribute(); $total = 0; foreach ($object->getQuote()->getAllVisibleItems() as $item) { if (parent::validate($item)) { $total += $item->getData($attr); } } return $this->validateAttribute($total); }
/** * @param \Magento\Rule\Model\Condition\Context $context * @param \Magento\SalesRule\Model\Rule\Condition\Product $ruleConditionProduct * @param array $data */ public function __construct(\Magento\Rule\Model\Condition\Context $context, \Magento\SalesRule\Model\Rule\Condition\Product $ruleConditionProduct, array $data = []) { parent::__construct($context, $ruleConditionProduct, $data); $this->setType('Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Found'); }