- Created front.js for handling frontend JavaScript functionalities. - Added index.php files for both the views and templates to manage redirection and access control. - Implemented configure.tpl for admin configuration settings with AJAX functionality for field retrieval. - Developed delete.tpl for product deletion with progress tracking. - Introduced file_upload.tpl for file upload handling with drag-and-drop support. - Created import.tpl for managing product imports with progress indicators. - Added list.tpl for displaying uploaded files with action links. - Implemented temp.tpl for queuing products with visual feedback. - Enhanced index.php for module access control. - Updated templates to include necessary JavaScript for AJAX operations and user interactions.
102 lines
3.3 KiB
PHP
102 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE
|
|
* With the purchase or the installation of the software in your application
|
|
* you accept the license agreement.
|
|
*
|
|
* You can not resell and redistribute this file.
|
|
*
|
|
* @author Dalibor Stojcevski <dal_sto@yahoo.com>
|
|
* @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'));
|
|
}
|
|
|
|
} |