private function addAmazonMarketplacesNotUpdatedNotificationMessage(\Ess\M2ePro\Controller\Adminhtml\Base $controller) { $outdatedMarketplaces = $this->getHelper('Data\\Cache\\Permanent')->getValue('amazon_outdated_marketplaces'); if ($outdatedMarketplaces === false) { $readConn = $this->resourceConnection->getConnection(); $dictionaryTable = $this->resourceConnection->getTableName('m2epro_amazon_dictionary_marketplace'); $rows = $readConn->select()->from($dictionaryTable, 'marketplace_id')->where('client_details_last_update_date IS NOT NULL')->where('server_details_last_update_date IS NOT NULL')->where('client_details_last_update_date < server_details_last_update_date')->query(); $ids = array(); foreach ($rows as $row) { $ids[] = $row['marketplace_id']; } $marketplacesCollection = $this->amazonFactory->getObject('Marketplace')->getCollection()->addFieldToFilter('status', \Ess\M2ePro\Model\Marketplace::STATUS_ENABLE)->addFieldToFilter('id', array('in' => $ids))->setOrder('sorder', 'ASC'); $outdatedMarketplaces = array(); /* @var $marketplace \Ess\M2ePro\Model\Marketplace */ foreach ($marketplacesCollection as $marketplace) { $outdatedMarketplaces[] = $marketplace->getTitle(); } $this->getHelper('Data\\Cache\\Permanent')->setValue('amazon_outdated_marketplaces', $outdatedMarketplaces, array('amazon', 'marketplace'), 60 * 60 * 24); } if (count($outdatedMarketplaces) <= 0) { return; } // M2ePro_TRANSLATIONS // %marketplace_title% data was changed on Amazon. You need to synchronize it the Extension works properly. Please, go to %menu_label% > <a href="%url%" target="_blank">Marketplaces</a> and click the Update All Now Button. $message = '%marketplace_title% data was changed on Amazon. You need to synchronize it ' . 'the Extension works properly. Please, go to %menu_path% > ' . '<a href="%url%" target="_blank">Marketplaces</a> and click the Update All Now Button.'; $controller->getMessageManager()->addNotice($this->getHelper('Module\\Translation')->__($message, implode(', ', $outdatedMarketplaces), $this->getHelper('View\\Amazon')->getPageNavigationPath('configuration'), $controller->getUrl('*/amazon_marketplace', array('tab' => \Ess\M2ePro\Helper\Component\Amazon::NICK))), \Ess\M2ePro\Controller\Adminhtml\Base::GLOBAL_MESSAGES_GROUP); }
private function addTokenExpirationDateNotificationMessage(\Ess\M2ePro\Controller\Adminhtml\Base $controller) { $tokenExpirationMessages = $this->getHelper('Data\\Cache\\Permanent')->getValue('ebay_accounts_token_expiration_messages'); if ($tokenExpirationMessages === false) { $tokenExpirationMessages = array(); $tempCollection = $this->ebayFactory->getObject('Account')->getCollection(); $tempCollection->getSelect()->reset(\Zend_Db_Select::COLUMNS); $tempCollection->getSelect()->columns(array('id', 'title')); $tempCollection->getSelect()->columns('token_expired_date', 'second_table'); $currentTimeStamp = $this->getHelper('Data')->getCurrentTimezoneDate(true); $format = $this->localeDate->getDateTimeFormat(\IntlDateFormatter::MEDIUM); foreach ($tempCollection->getData() as $accountData) { $tokenExpirationTimeStamp = strtotime($accountData['token_expired_date']); // M2ePro_TRANSLATIONS /* The token for "%account_title%" eBay Account has been expired.<br/> Please, go to %menu_label% > Configuration > eBay Account > <a href="%url%" target="_blank">General TAB</a>, click on the Get Token button. (You will be redirected to the eBay website.) Sign-in and press I Agree on eBay Page. Do not forget to press Save button after returning back to Magento */ $textToTranslate = 'The token for "%account_title%" eBay Account has been expired.<br/>' . 'Please, go to %menu_label% > Configuration > eBay Account >' . '<a href="%url%" target="_blank">General TAB</a>, click on the Get Token Button.' . '(You will be redirected to the eBay website.) Sign-in and press I Agree on eBay Page.' . 'Do not forget to press Save Button after returning back to Magento'; if ($tokenExpirationTimeStamp < $currentTimeStamp) { $tempMessage = $this->getHelper('Module\\Translation')->__(trim($textToTranslate), $this->getHelper('Data')->escapeHtml($accountData['title']), $this->getHelper('View\\Ebay')->getMenuRootNodeLabel(), $controller->getUrl('*/adminhtml_ebay_account/edit', array('id' => $accountData['id']))); $tokenExpirationMessages[] = array('type' => 'error', 'message' => $tempMessage); continue; } // M2ePro_TRANSLATIONS /* Attention! The token for "%account_title%" eBay Account will be expired soon ( %date% ). <br/>Please, go to %menu_label% > Configuration > eBay Account > <a href="%url%" target="_blank">General TAB</a>, click on the Get Token Button. (You will be redirected to the eBay website.) Sign-in and press I Agree on eBay Page. Do not forget to press Save Button after returning back to Magento */ $textToTranslate = 'Attention! The token for "%account_title%" eBay Account will be expired soon ( %date% ).' . '<br/>Please, go to %menu_label% > Configuration > eBay Account >' . '<a href="%url%" target="_blank">General TAB</a>, click on the Get Token Button.' . '(You will be redirected to the eBay website.) Sign-in and press I Agree on eBay Page.' . 'Do not forget to press Save Button after returning back to Magento'; if ($currentTimeStamp + 60 * 60 * 24 * 10 >= $tokenExpirationTimeStamp) { $tempMessage = $this->getHelper('Module\\Translation')->__(trim($textToTranslate), $this->getHelper('Data')->escapeHtml($accountData['title']), $this->localeDate->date(strtotime($accountData['token_expired_date']))->toString($format), $this->getHelper('View_Ebay')->getMenuRootNodeLabel(), $controller->getUrl('*/adminhtml_ebay_account/edit', array('id' => $accountData['id']))); $tokenExpirationMessages[] = array('type' => 'notice', 'message' => $tempMessage); continue; } } $this->getHelper('Data\\Cache\\Permanent')->setValue('ebay_accounts_token_expiration_messages', $tokenExpirationMessages, array('account', 'ebay'), 60 * 60 * 24); } foreach ($tokenExpirationMessages as $messageData) { $method = 'add' . ucfirst($messageData['type']); $controller->getMessageManager()->{$method}($messageData['message'], \Ess\M2ePro\Controller\Adminhtml\Base::GLOBAL_MESSAGES_GROUP); } }