![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-sales-rule/Model/Rule/Condition/Product/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\SalesRule\Model\Rule\Condition\Product; class Found extends \Magento\SalesRule\Model\Rule\Condition\Product\Combine { /** * @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::class); } /** * Load value options * * @return $this */ public function loadValueOptions() { $this->setValueOption([1 => __('FOUND'), 0 => __('NOT FOUND')]); return $this; } /** * Return as html * * @return string */ public function asHtml() { $html = $this->getTypeElement()->getHtml() . __( "If an item is %1 in the cart with %2 of these conditions true:", $this->getValueElement()->getHtml(), $this->getAggregatorElement()->getHtml() ); if ($this->getId() != '1') { $html .= $this->getRemoveLinkHtml(); } return $html; } /** * Validate * * @param \Magento\Framework\Model\AbstractModel $model * @return bool * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function validate(\Magento\Framework\Model\AbstractModel $model) { $isValid = false; foreach ($model->getAllItems() as $item) { if (parent::validate($item)) { $isValid = true; break; } } return $isValid; } }