name = 'empikmarketplace'; $this->version = '1.6.5'; $this->author = 'Waynet'; $this->tab = 'market_place'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('EmpikPlace'); $this->description = $this->l('Integration with Empik Marketplace'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall this module?'); $this->controllers = ['cron']; $this->ps_versions_compliancy = ['min' => '1.6', 'max' => _PS_VERSION_]; } public function getService($serviceName) { if (!isset($this->serviceContainer)) { $this->serviceContainer = new PrestaShop\ModuleLibServiceContainer\DependencyInjection\ServiceContainer( $this->name, $this->getLocalPath() ); } return $this->serviceContainer->getService($serviceName); } private static function safeAddColumn($table, $column, $def) { $count = Db::getInstance()->getValue('SELECT count(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME=\'' . $column . '\' AND TABLE_NAME=\'' . _DB_PREFIX_ . $table . '\''); if (!$count) return Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . $table . '` ADD `' . $column . '` ' . $def); return true; } public function install() { $return = true; $return &= parent::install(); $return &= $this->getInstaller()->install(); $return &= self::safeAddColumn('empik_product', 'condition', 'INT(4) NOT NULL DEFAULT 11 AFTER logistic_class'); return (bool)$return; } public function getInstaller() { if (!isset($this->installer)) { $this->installer = $this->getService('empik.marketplace.install.installer'); } return $this->installer; } public function uninstall() { $return = true; $return &= $this->getUninstaller()->uninstall(); $return &= parent::uninstall(); return (bool)$return; } public function getUninstaller() { if (!isset($this->uninstaller)) { $this->uninstaller = $this->getService('empik.marketplace.install.uninstaller'); } return $this->uninstaller; } public function isUsingNewTranslationSystem() { return false; } public function getAdminTabs() { /** @var \Empik\Marketplace\PrestaShopContext $prestaShopContext */ $prestaShopContext = $this->getService('empik.marketplace.prestaShopContext'); return [ [ 'className' => 'AdminEmpik', 'parent' => $prestaShopContext->is17() ? 'SELL' : 0, 'name' => $this->l('Empik'), 'module' => $this->name, 'active' => true, 'icon' => 'next_week', ], [ 'className' => 'AdminEmpikConnection', 'parent' => 'AdminEmpik', 'name' => $this->l('Connection'), 'module' => $this->name, 'active' => true, 'icon' => '', ], [ 'className' => 'AdminEmpikProducts', 'parent' => 'AdminEmpik', 'name' => $this->l('Products'), 'module' => $this->name, 'active' => true, 'icon' => '', ], [ 'className' => 'AdminEmpikProductsPrice', 'parent' => 'AdminEmpik', 'name' => $this->l('Products parameters'), 'module' => $this->name, 'active' => true, 'icon' => '', ], [ 'className' => 'AdminEmpikOffers', 'parent' => 'AdminEmpik', 'name' => $this->l('Offers'), 'module' => $this->name, 'active' => true, 'icon' => '', ], [ 'className' => 'AdminEmpikOrders', 'parent' => 'AdminEmpik', 'name' => $this->l('Orders'), 'module' => $this->name, 'active' => true, 'icon' => '', ], [ 'className' => 'AdminEmpikActionLog', 'parent' => 'AdminEmpik', 'name' => $this->l('Last actions'), 'module' => $this->name, 'active' => true, 'icon' => '', ], [ 'className' => 'AdminEmpikHelp', 'parent' => 'AdminEmpik', 'name' => $this->l('Help'), 'module' => $this->name, 'active' => true, 'icon' => '', ], ]; } protected function getHookAction() { if (!isset($this->hookAction)) { $this->hookAction = $this->getService('empik.marketplace.hook.hookAction'); } return $this->hookAction; } public function hookActionAdminOrdersListingFieldsModifier($params) { $this->getHookAction()->hookActionAdminOrdersListingFieldsModifier($params); } public function hookActionOrderGridDefinitionModifier(array $params) { $this->getHookAction()->hookActionOrderGridDefinitionModifier($params); } public function hookActionOrderGridQueryBuilderModifier(array $params) { $this->getHookAction()->hookActionOrderGridQueryBuilderModifier($params); } public function hookActionAdminOrdersTrackingNumberUpdate($params) { $this->getHookAction()->hookActionAdminOrdersTrackingNumberUpdate($params); } public function hookActionOrderHistoryAddAfter($params) { $this->getHookAction()->hookActionOrderHistoryAddAfter($params); } public function hookDisplayAdminOrderSideBottom(array $params) { return $this->getHookAction()->hookDisplayAdminOrder($params); } public function hookDisplayAdminOrderLeft(array $params) { return $this->getHookAction()->hookDisplayAdminOrder($params); } public function hookActionAdminControllerSetMedia($params) { return $this->getHookAction()->hookActionAdminControllerSetMedia($params); } public function hookActionObjectProductDeleteBefore($params) { return $this->getHookAction()->hookActionObjectProductDeleteBefore($params); } public function setAuthStatus() { $env = Configuration::get(Empik\Marketplace\Adapter\ConfigurationAdapter::CONF_ENVIRONMENT); $apiKey = Configuration::get(Empik\Marketplace\Adapter\ConfigurationAdapter::CONF_API_KEY); Configuration::updateValue( Empik\Marketplace\Adapter\ConfigurationAdapter::CONF_AUTH_STATUS, md5($env.$apiKey) ); } /** @return bool */ public function getAuthStatus() { $env = Configuration::get(Empik\Marketplace\Adapter\ConfigurationAdapter::CONF_ENVIRONMENT); $apiKey = Configuration::get(Empik\Marketplace\Adapter\ConfigurationAdapter::CONF_API_KEY); $status = Configuration::get(Empik\Marketplace\Adapter\ConfigurationAdapter::CONF_AUTH_STATUS); return $status === md5($env.$apiKey); } }