This commit is contained in:
2026-02-08 21:43:11 +01:00
parent 45b32a5ee2
commit 58947ad589
33 changed files with 3262 additions and 1597 deletions

View File

@@ -1,5 +1,7 @@
<?php
use Empik\Marketplace\Helper\VersionHelper;
if (!defined('_PS_VERSION_')) {
exit;
}
@@ -20,6 +22,10 @@ class EmpikMarketplace extends Module
'displayAdminOrderLeft',
];
const HOOK_LIST_8 = [
'actionBeforeUpgradeModule',
];
const HOOK_LIST_17 = [
'actionOrderGridDefinitionModifier',
'actionOrderGridQueryBuilderModifier',
@@ -38,7 +44,7 @@ class EmpikMarketplace extends Module
public function __construct()
{
$this->name = 'empikmarketplace';
$this->version = '2.0.0';
$this->version = '2.0.2';
$this->author = 'Waynet';
$this->tab = 'market_place';
$this->need_instance = 0;
@@ -66,23 +72,15 @@ class EmpikMarketplace extends Module
return $this->serviceContainer->getService($serviceName);
}
public 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;
$currentVersion = VersionHelper::getInstalledVersion($this);
$return &= parent::install();
$return &= $this->getInstaller()->install();
$return &= self::safeAddColumn('empik_product', 'condition', 'INT(4) NOT NULL DEFAULT 11 AFTER logistic_class');
$return &= self::safeAddColumn('empik_product', 'export_original_price', 'INT(1) NOT NULL DEFAULT 0 AFTER logistic_class');
$return &= (new \Empik\Marketplace\Update\UpdateRunner($currentVersion, $this))->run();
return (bool)$return;
}
@@ -247,6 +245,22 @@ class EmpikMarketplace extends Module
return $this->getHookAction()->hookActionObjectProductDeleteBefore($params);
}
public function hookActionBeforeUpgradeModule($params)
{
if (!isset($params['moduleName']) || !empty($params['source'])) {
return;
}
if ($params['moduleName'] != $this->name) {
return;
}
$currentVersion = VersionHelper::getInstalledVersion($this);
$runner = new Empik\Marketplace\Update\UpdateRunner($currentVersion, $this);
return $runner->run();
}
public function setAuthStatus()
{
$env = Configuration::get(Empik\Marketplace\Adapter\ConfigurationAdapter::CONF_ENVIRONMENT);