Exemplo n.º 1
0
 /**
  * Check if event can be matched by process.
  * Overwrote for specific config save, store and store groups save matching
  *
  * @param \Magento\Index\Model\Event $event
  * @return bool
  */
 public function matchEvent(\Magento\Index\Model\Event $event)
 {
     $data = $event->getNewData();
     if (isset($data[self::EVENT_MATCH_RESULT_KEY])) {
         return $data[self::EVENT_MATCH_RESULT_KEY];
     }
     $entity = $event->getEntity();
     if ($entity == \Magento\Store\Model\Store::ENTITY) {
         $store = $event->getDataObject();
         if ($store && ($store->isObjectNew() || $store->dataHasChangedFor('group_id'))) {
             $result = true;
         } else {
             $result = false;
         }
     } else {
         if ($entity == \Magento\Store\Model\Group::ENTITY) {
             /** @var \Magento\Store\Model\Group $storeGroup */
             $storeGroup = $event->getDataObject();
             $hasDataChanges = $storeGroup && ($storeGroup->dataHasChangedFor('root_category_id') || $storeGroup->dataHasChangedFor('website_id'));
             if ($storeGroup && !$storeGroup->isObjectNew() && $hasDataChanges) {
                 $result = true;
             } else {
                 $result = false;
             }
         } else {
             if ($entity == \Magento\Framework\App\Config\ValueInterface::ENTITY) {
                 $configData = $event->getDataObject();
                 if ($configData && in_array($configData->getPath(), $this->_relatedConfigSettings)) {
                     $result = $configData->isValueChanged();
                 } else {
                     $result = false;
                 }
             } else {
                 $result = parent::matchEvent($event);
             }
         }
     }
     $event->addNewData(self::EVENT_MATCH_RESULT_KEY, $result);
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Check if event can be matched by process
  * Overwrote for check is flat catalog product is enabled and specific save
  * attribute, store, store_group
  *
  * @param Event $event
  * @return bool
  */
 public function matchEvent(Event $event)
 {
     $data = $event->getNewData();
     if (isset($data[self::EVENT_MATCH_RESULT_KEY])) {
         return $data[self::EVENT_MATCH_RESULT_KEY];
     }
     $entity = $event->getEntity();
     if ($entity == Attribute::ENTITY) {
         /* @var $attribute Attribute */
         $attribute = $event->getDataObject();
         if (!$attribute) {
             $result = false;
         } elseif ($event->getType() == Event::TYPE_SAVE) {
             $result = $attribute->dataHasChangedFor('is_searchable');
         } elseif ($event->getType() == Event::TYPE_DELETE) {
             $result = $attribute->getIsSearchable();
         } else {
             $result = false;
         }
     } else {
         if ($entity == Store::ENTITY) {
             if ($event->getType() == Event::TYPE_DELETE) {
                 $result = true;
             } else {
                 /* @var $store Store */
                 $store = $event->getDataObject();
                 if ($store && $store->isObjectNew()) {
                     $result = true;
                 } else {
                     $result = false;
                 }
             }
         } else {
             if ($entity == Group::ENTITY) {
                 /* @var $storeGroup Group */
                 $storeGroup = $event->getDataObject();
                 if ($storeGroup && $storeGroup->dataHasChangedFor('website_id')) {
                     $result = true;
                 } else {
                     $result = false;
                 }
             } else {
                 if ($entity == ValueInterface::ENTITY) {
                     $data = $event->getDataObject();
                     if ($data && in_array($data->getPath(), $this->_relatedConfigSettings)) {
                         $result = $data->isValueChanged();
                     } else {
                         $result = false;
                     }
                 } else {
                     $result = parent::matchEvent($event);
                 }
             }
         }
     }
     $event->addNewData(self::EVENT_MATCH_RESULT_KEY, $result);
     return $result;
 }