/** * If it's configured to capture on shipment - do this. * * @param \Magento\Framework\Event\Observer $observer * * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $dataObject = $observer->getEvent()->getDataObject(); if ($dataObject->getCustomerId() && $dataObject->getStatusId() == \Magento\Review\Model\Review::STATUS_APPROVED) { $customerId = $dataObject->getCustomerId(); $this->helper->setConnectorContactToReImport($customerId); //save review info in the table $this->registerReview($dataObject); $store = $this->storeManager->getStore($dataObject->getStoreId()); $storeName = $store->getName(); $website = $this->storeManager->getStore($store)->getWebsite(); $customer = $this->customerFactory->create()->load($customerId); //if api is not enabled if (!$this->helper->isEnabled($website)) { return $this; } $programId = $this->helper->getWebsiteConfig('connector_automation/visitor_automation/review_automation'); if ($programId) { $automation = $this->automationFactory->create(); $automation->setEmail($customer->getEmail())->setAutomationType(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_REVIEW)->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)->setTypeId($dataObject->getReviewId())->setWebsiteId($website->getId())->setStoreName($storeName)->setProgramId($programId); $automation->save(); } } return $this; }