/** * Builds event body for API * @param \Magento\Framework\Event $event * @return \Koklu\Event\Model\Event */ public function buildEventBody(\Magento\Framework\Event $event) { $product = $this->_productResource->getProduct($event->getProduct()->getId(), false); // we do not need to send an event if product is disabled or invisible $allowedVisibility = [Visibility::VISIBILITY_IN_CATALOG, Visibility::VISIBILITY_BOTH]; if ($product->getStatus() != Status::STATUS_ENABLED || !in_array($product->getVisibility(), $allowedVisibility)) { // however if the changes involved status or visibility, then we need to send a delete event // if ($event->getProduct()->dataHasChangedFor('status') // || $event->getProduct()->dataHasChangedFor('visibility') // ) { $this->_eventManager->dispatch('koklu_masterdata_not_salable_product_save', ['product' => $product]); // } return null; } return new Event(self::EVENT_SUBJECT, $this->_productBuilder->create($product)); }
/** * Builds event body for API * @param \Magento\Framework\Event $event * @return Event */ public function buildEventBody(\Magento\Framework\Event $event) { return new Event(self::EVENT_SUBJECT, ['sku' => $event->getProduct()->getSku()]); }
/** * Builds event body for API * @param \Magento\Framework\Event $event * @return Event */ public function buildEventBody(\Magento\Framework\Event $event) { return new Event(static::SUBJECT, ['user_id' => $this->_userHelper->getUserId(), 'sku' => $event->getProduct()->getSku()]); }