* @copyright 2019 Dalibor Stojcevski * @license Dalibor Stojcevski */ if (!defined('_PS_VERSION_')) { exit; } class import_api extends Module { protected $config_form = false; protected $_postErrors = array(); protected $fmr_fields; public function __construct() { $this->name = 'import_api'; $this->tab = 'front_office_features'; $this->version = '3.1.5.9'; $this->author = 'Dalibor Stojcevski'; $this->need_instance = 1; $this->bootstrap = true; $this->module_key = '3711c016ea39f2f2aa38850e48aa7455'; parent::__construct(); $this->displayName = $this->l('Import Api'); $this->description = $this->l('Import and update products from external source'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->frm_fields = ['unique', 'reference', 'name', 'description', 'price', 'quantity', 'images', 'cover', 'brand', 'category', 'category_parent', 'ean13', 'upc', 'condition', 'weight', 'feature', 'feature_value']; $this->frm_settings = array('top_category' => '', 'default_category' => '', 'default_brand' => '', 'price_multiplier' => '', 'category_path' => 0); } public function install() { $class = 'AdminImport_Api'; $tab = new Tab(); $tab->class_name = $class; $tab->module = $this->name; $tab->id_parent = 0; $langs = Language::getLanguages(false); foreach ($langs as $l) { $tab->name[$l['id_lang']] = $this->l('Import Products'); } $tab->save(); return $this->installDb() && parent::install(); } public function uninstall() { return parent::uninstall(); } public function installDb() { $return = true; require_once(_PS_MODULE_DIR_ . 'import_api/sql_install.php'); foreach ($sql as $s) { Db::getInstance()->execute($s); } $res = Db::getInstance()->executeS("SHOW columns FROM `"._DB_PREFIX_."ia_files` LIKE 'status'"); if (!$res) { Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'ia_files` ADD `status` SMALLINT(2) NOT NULL DEFAULT \'1\''); } $res_1 = Db::getInstance()->executeS("SHOW columns FROM `"._DB_PREFIX_."ia_file_settings` LIKE 'replace' "); if (!$res_1) { Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'ia_file_settings` ADD `replace` text NOT NULL'); } $res_2 = Db::getInstance()->executeS("SHOW columns FROM `"._DB_PREFIX_."ia_file_settings` LIKE 'filter' "); if (!$res_2) { Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'ia_file_settings` ADD `filter` text NOT NULL'); } $res_3 = Db::getInstance()->executeS("SHOW columns FROM `"._DB_PREFIX_."ia_file_settings` LIKE 'filter_options' "); if (!$res_3) { Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'ia_file_settings` ADD `filter_options` text NOT NULL'); } return $return; } public function getContent() { Tools::redirectAdmin($this->context->link->getAdminLink('AdminImport_Api')); } }