customerSession = $customerSession; $this->helper = $helper; $this->response = $response; $this->urlFactory = $urlFactory; } /** * @param \Magento\Newsletter\Controller\Manage\Index $subject * @param callable $proceed */ public function aroundExecute( \Magento\Newsletter\Controller\Manage\Index $subject, callable $proceed ) { $websiteId = $this->customerSession->getCustomer()->getWebsiteId(); $isEnabled = $this->helper->isEnabled($websiteId); $dataFields = $this->helper->getCanShowDataFields( $websiteId ); $addressBooks = $this->helper->getCanShowAdditionalSubscriptions( $websiteId ); $preferences = $this->helper->getWebsiteConfig( \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SHOW_PREFERENCES, $websiteId ); if ($isEnabled && ($dataFields || $addressBooks || $preferences)) { $this->response->setRedirect( $this->urlFactory->create()->getUrl('connector/customer/index') ); } else { return $proceed(); } } }