/**
  * DataProvider constructor.
  * @param string $name
  * @param string $primaryFieldName
  * @param string $requestFieldName
  * @param CollectionFactory $collectionFactory
  * @param Store $store
  * @param GroupRepositoryInterface $groupRepository
  * @param SearchCriteriaBuilder $searchCriteriaBuilder
  * @param DataObject $objectConverter
  * @param array $meta
  * @param array $data
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct($name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, Store $store, GroupRepositoryInterface $groupRepository, SearchCriteriaBuilder $searchCriteriaBuilder, DataObject $objectConverter, array $meta = [], array $data = [])
 {
     parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
     $this->collection = $collectionFactory->create();
     $this->store = $store;
     $this->groupRepository = $groupRepository;
     $this->searchCriteriaBuilder = $searchCriteriaBuilder;
     $this->objectConverter = $objectConverter;
     $this->initMeta();
 }
 /**
  * Check rules that contains affected attribute
  * If rules were found they will be set to inactive and notice will be add to admin session
  *
  * @param string $attributeCode
  * @return $this
  */
 protected function checkCatalogRulesAvailability($attributeCode)
 {
     /* @var $collection RuleCollectionFactory */
     $collection = $this->ruleCollectionFactory->create()->addAttributeInConditionFilter($attributeCode);
     $disabledRulesCount = 0;
     foreach ($collection as $rule) {
         /* @var $rule Rule */
         $rule->setIsActive(0);
         /* @var $rule->getConditions() Combine */
         $this->removeAttributeFromConditions($rule->getConditions(), $attributeCode);
         $rule->save();
         $disabledRulesCount++;
     }
     if ($disabledRulesCount) {
         $this->ruleProductProcessor->markIndexerAsInvalid();
         $this->messageManager->addWarning(__('You disabled %1 Catalog Price Rules based on "%2" attribute.', $disabledRulesCount, $attributeCode));
     }
     return $this;
 }
Exemple #3
0
 /**
  * Get active rules
  *
  * @return array
  */
 protected function getAllRules()
 {
     return $this->ruleCollectionFactory->create();
 }
 /**
  * @param string $name
  * @param string $primaryFieldName
  * @param string $requestFieldName
  * @param CollectionFactory $collectionFactory
  * @param DataPersistorInterface $dataPersistor
  * @param array $meta
  * @param array $data
  */
 public function __construct($name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = [])
 {
     $this->collection = $collectionFactory->create();
     $this->dataPersistor = $dataPersistor;
     parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
 }