* @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL * @license https://opensource.org/licenses/MIT The MIT License * * Don't forget to prefix your containers with your own identifier * to avoid any conflicts with others containers. */ require_once(dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'); class RetailcrmSyncEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { /** * @inheritDoc */ public function execute() { if ($this->isRunning()) { return false; } $this->setRunning(); $shops = $this->getShops(); foreach ($shops as $shop) { RetailcrmTools::setShopContext(intval($shop['id_shop'])); if (!Configuration::get(RetailCRM::ENABLE_HISTORY_UPLOADS)) { RetailcrmLogger::writeDebug( __METHOD__, 'History uploads is not enabled, skipping...' ); continue; } $apiUrl = Configuration::get(RetailCRM::API_URL); $apiKey = Configuration::get(RetailCRM::API_KEY); RetailcrmHistory::$default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); if (!empty($apiUrl) && !empty($apiKey)) { RetailcrmHistory::$api = new RetailcrmProxy($apiUrl, $apiKey, RetailcrmLogger::getLogFile()); } else { RetailcrmLogger::writeCaller(__METHOD__, 'Set api key & url first'); continue; } RetailcrmHistory::customersHistory(); RetailcrmHistory::ordersHistory(); } return true; } /** * @inheritDoc */ public function getName() { return 'RetailcrmSyncEvent'; } }