/** * settings keys * * @return array */ public static function getSettingKeys() { return array_keys(ShopgateSettings::getDefaultSettings()); }
/** * install * * @return bool */ public function install() { /** * delete shopgate config */ Configuration::deleteByName(ShopgateConfigPrestashop::DEFAULT_CONFIG_NAME); /** * hooks */ $registerHooks = array('header', 'adminOrder', 'updateOrderStatus', 'updateQuantity'); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $registerHooks[] = 'displayMobileHeader'; $registerHooks[] = 'actionUpdateQuantity'; } /** * enable debug */ ShopgateLogger::getInstance()->enableDebug(); /** * set default settings */ $this->configurations = ShopgateSettings::getDefaultSettings(); /** * check parent install */ ShopGate::log('INSTALLATION - calling parent::install()', ShopgateLogger::LOGTYPE_DEBUG); $result = parent::install(); if (!$result) { ShopGate::log('parent::install() failed; return value: ' . var_export($result, true), ShopgateLogger::LOGTYPE_ERROR); return false; } /** * check installed php extensions */ $missingExtensions = ShopgateHelper::checkLoadedExtensions(array('curl')); if (count($missingExtensions) > 0) { foreach ($missingExtensions as $missingExtension) { ShopGate::log(sprintf('Installation failed. %s is not installed or loaded.', $missingExtension), ShopgateLogger::LOGTYPE_ERROR); } return false; } /** * register hooks */ $this->registerHooks($registerHooks); /** * install tables */ if (!$this->installTables()) { return false; } /** * update tables */ if (!$this->updateTables()) { return false; } /** * install shopgate carrier */ $this->shopgateShippingModel->createShopgateCarrier(); /** * order states */ ShopGate::log('INSTALLATION - adding order states', ShopgateLogger::LOGTYPE_DEBUG); $this->addOrderState('PS_OS_SHOPGATE', $this->l('Shipping blocked (Shopgate)')); /** * save default configuration */ ShopGate::log('INSTALLATION - setting config values', ShopgateLogger::LOGTYPE_DEBUG); $this->configurations['SG_LANGUAGE_ID'] = Configuration::get('PS_LANG_DEFAULT'); foreach ($this->configurations as $name => $value) { if (!Configuration::updateValue($name, $value)) { ShopGate::log(sprintf('installation failed: unable to save configuration setting "%s" with value "%s"', var_export($name, true), var_export($value, true)), ShopgateLogger::LOGTYPE_ERROR); return false; } } /** @todo register plugin */ ShopGate::log('INSTALLATION - installation was successful', ShopgateLogger::LOGTYPE_DEBUG); return true; }