Author: Aurelien FOUCRET (aurelien.foucret@smile.fr)
Inheritance: extends Magento\Rule\Model\AbstractModel
Exemple #1
0
 /**
  * Constructor.
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  *
  * @param \Magento\Framework\Model\Context                                                         $context                   Context.
  * @param \Magento\Framework\Registry                                                              $registry                  Registry.
  * @param \Magento\Framework\Data\FormFactory                                                      $formFactory               Form factory.
  * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface                                     $localeDate                Locale date.
  * @param \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\CombineFactory                       $combineConditionsFactory  Search engine rule (combine) condition factory.
  * @param \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\ProductFactory                       $productConditionsFactory  Search engine rule (product) condition factory.
  * @param \Smile\ElasticsuiteCore\Search\Request\Query\QueryFactory                                $queryFactory              Search query factory.
  * @param \Magento\Catalog\Model\CategoryFactory                                                   $categoryFactory           Product category factorty.
  * @param \Smile\ElasticsuiteVirtualCategory\Model\ResourceModel\VirtualCategory\CollectionFactory $categoryCollectionFactory Virtual categories collection factory.
  * @param \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\QueryBuilder                 $queryBuilder              Search rule query builder.
  * @param array                                                                                    $data                      Additional data.
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\CombineFactory $combineConditionsFactory, \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\ProductFactory $productConditionsFactory, \Smile\ElasticsuiteCore\Search\Request\Query\QueryFactory $queryFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Smile\ElasticsuiteVirtualCategory\Model\ResourceModel\VirtualCategory\CollectionFactory $categoryCollectionFactory, \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\QueryBuilder $queryBuilder, array $data = [])
 {
     $this->queryFactory = $queryFactory;
     $this->productConditionsFactory = $productConditionsFactory;
     $this->categoryFactory = $categoryFactory;
     $this->categoryCollectionFactory = $categoryCollectionFactory;
     $this->queryBuilder = $queryBuilder;
     parent::__construct($context, $registry, $formFactory, $localeDate, $combineConditionsFactory, $data);
 }
Exemple #2
0
 /**
  * Render HTML of the element using the rule engine.
  *
  * @return string
  */
 public function getInputHtml()
 {
     $this->rule->setElementName($this->element->getName());
     if ($this->element->getValue()) {
         /* Hack : reload in a new instance to have element name set.
          *        can not be done in afterLoad of the backend model
          *        since we do not know yet the form structure
          */
         $conditions = $this->element->getValue()->getConditions()->asArray();
         $this->rule->getConditions()->loadArray($conditions);
         $this->element->setRule($this->rule);
     }
     $this->input = $this->elementFactory->create('text');
     $this->input->setRule($this->rule)->setRenderer($this->conditions);
     return $this->input->toHtml();
 }