first commit

This commit is contained in:
2024-11-11 18:46:54 +01:00
commit a630d17338
25634 changed files with 4923715 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_4_0_0($module)
{
$dbCharset = DbAdapter::getUtf8Collation();
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro__cats_list`');
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro__sell_form_fields`');
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account`
MODIFY `password` varchar(255) NOT NULL,
ADD `verkey` bigint(20) unsigned NOT NULL DEFAULT 0,
ADD `vercats` char(16) NOT NULL DEFAULT 0,
ADD `verforms` char(16) NOT NULL DEFAULT 0'
);
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_category` ADD `features` longtext NULL');
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro__cats_list` (
`country_code` int(10) unsigned NOT NULL,
`sandbox` tinyint(1) unsigned NOT NULL,
`id` int(10) unsigned NOT NULL,
`name` varchar(128),
`parent_id` int(10) unsigned,
`position` int(10) unsigned,
PRIMARY KEY(`country_code`, `sandbox`, `id`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro__sell_form_fields` (
`country_code` int(10) unsigned NOT NULL,
`sandbox` tinyint(1) unsigned NOT NULL,
`sell_form_id` int(10) unsigned NOT NULL,
`sell_form_title` varchar(255),
`sell_form_cat` int(10) unsigned,
`sell_form_type` int(10) unsigned,
`sell_form_res_type` int(10) unsigned,
`sell_form_def_value` int(10) unsigned,
`sell_form_opt` int(10) unsigned,
`sell_form_pos` int(10) unsigned,
`sell_form_length` int(10) unsigned,
`sell_min_value` decimal(10,2),
`sell_max_value` decimal(10,2),
`sell_form_desc` text,
`sell_form_opts_values` text,
`sell_form_field_desc` text,
`sell_form_param_id` int(10) unsigned,
`sell_form_param_values` text,
`sell_form_parent_id` int(10) unsigned,
`sell_form_parent_value` int(10) unsigned,
`sell_form_unit` varchar(16),
`sell_form_options` int(10) unsigned,
PRIMARY KEY(`country_code`, `sandbox`, `sell_form_id`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
foreach (array(
'INPOST_LETTER' => 7.20,
'INPOST_MACHINE' => 8.60,
'INPOST_MACHINE_COD' => 12.10,
'INPOST_CARRIER' => 12.18,
'INPOST_CARRIER_COD' => 15.68,
'LOCK_SYNC' => 0,
'PAGE_SYNC' => 0,
// not longer supported settings, set to default
'OVERLAY_UNDER_IMAGE' => 0,
'XALLEGRO_RENEWAL_SETTINGS' => 4
) as $key => $value
) {
XAllegroConfiguration::updateValue($key, $value);
}
$module->reinstallTabs();
$module->registerHook('actionAdminControllerSetMedia');
$module->uninstallOverrides();
return true;
}

View File

@@ -0,0 +1,21 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_0_1()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
XAllegroConfiguration::updateValue('IMPORT_ORDERS_CHUNK', 25);
return true;
}

View File

@@ -0,0 +1,26 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_0_2()
{
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_form` ADD `processed` tinyint(1) unsigned NOT NULL DEFAULT 0');
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_form` xf
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o
ON (xf.`id_order` = o.`id_order`)
SET `processed` = 1
WHERE xf.`content` <> ""
AND xf.`processed` = 0'
);
return true;
}

View File

@@ -0,0 +1,28 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_0_4()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
XAllegroConfiguration::updateValue('PAGE_SYNC', 0);
// fix duplication on some servers
XAllegroConfiguration::deleteByName('LOCK_SYNC');
XAllegroConfiguration::updateValue('LOCK_SYNC', 0);
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_template` ADD `is_new` tinyint(1) unsigned NOT NULL DEFAULT 0');
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_configuration` ADD CONSTRAINT conf_name UNIQUE (`name`)');
return true;
}

View File

@@ -0,0 +1,23 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_0_5()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
if ((int)XAllegroConfiguration::get('DURATION_DEFAULT') == 4) {
XAllegroConfiguration::updateValue('DURATION_DEFAULT', 3);
}
return true;
}

View File

@@ -0,0 +1,26 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_4_0_8($module)
{
/**
* @since 4.2.0
* No possibility to migrate suppliers and categories from older versions
*/
Db::getInstance()->execute('TRUNCATE TABLE `' . _DB_PREFIX_ . 'xallegro_status`');
Db::getInstance()->execute('TRUNCATE TABLE `' . _DB_PREFIX_ . 'xallegro_category`');
Db::getInstance()->execute('TRUNCATE TABLE `' . _DB_PREFIX_ . 'xallegro_pas`');
$module->config->installStatuses();
return true;
}

View File

@@ -0,0 +1,116 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
/**
* @return bool
*/
function upgrade_module_4_1_0()
{
$dbCharset = DbAdapter::getUtf8Collation();
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account`
DROP `shop`,
DROP `country`,
DROP `country_code`,
ADD `rest_apikey` char(255) NOT NULL AFTER `password`,
ADD `client_secret` char(255) NOT NULL AFTER `password`,
ADD `client_id` char(255) NOT NULL AFTER `password`,
ADD `return_policy` char(64) NULL AFTER `sandbox`,
ADD `warranty` char(64) NULL AFTER `sandbox`,
ADD `implied_warranty` char(64) NULL AFTER `sandbox`,
ADD `access_token` text NULL,
ADD `refresh_token` text NULL,
ADD `expire_authorization` datetime NOT NULL DEFAULT "2016-01-01 00:00:00",
ADD `expire_refresh` datetime NOT NULL DEFAULT "2016-01-01 00:00:00",
MODIFY `password` char(255) NULL,
CHANGE `apikey` `web_apikey` char(255) NOT NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
ADD `id_xallegro_account` int(10) unsigned NOT NULL AFTER `id_xallegro_auction`'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_pas`
MODIFY `invoice` int(10) unsigned NOT NULL'
);
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro_site`');
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro__cats_list`');
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro__sell_form_fields`');
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_pas`
SET `invoice` = 32
WHERE `invoice` = 1'
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro__cats_list` (
`sandbox` tinyint(1) unsigned NOT NULL,
`id` int(10) unsigned NOT NULL,
`name` char(128) NULL,
`parent_id` int(10) unsigned NULL,
`position` int(10) unsigned NULL,
`is_leaf` tinyint(1) unsigned NULL,
PRIMARY KEY(`sandbox`, `id`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro__sell_form_fields` (
`sandbox` tinyint(1) unsigned NOT NULL,
`sell_form_id` int(10) unsigned NOT NULL,
`sell_form_title` char(255),
`sell_form_cat` int(10) unsigned,
`sell_form_type` int(10) unsigned,
`sell_form_res_type` int(10) unsigned,
`sell_form_def_value` int(10) unsigned,
`sell_form_opt` int(10) unsigned,
`sell_form_pos` int(10) unsigned,
`sell_form_length` int(10) unsigned,
`sell_min_value` decimal(10,2),
`sell_max_value` decimal(10,2),
`sell_form_desc` text,
`sell_form_opts_values` text,
`sell_form_field_desc` text,
`sell_form_param_id` int(10) unsigned,
`sell_form_param_values` text,
`sell_form_parent_id` int(10) unsigned,
`sell_form_parent_value` int(10) unsigned,
`sell_form_unit` char(16),
`sell_form_options` int(10) unsigned,
PRIMARY KEY(`sandbox`, `sell_form_id`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_auction`
SET `id_xallegro_account` = `id_allegro_account`'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
DROP INDEX `id_allegro_account`,
DROP PRIMARY KEY,
DROP `id_allegro_account`,
ADD PRIMARY KEY (`id_xallegro_auction`, `id_xallegro_account`)'
);
return true;
}

View File

@@ -0,0 +1,21 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_1_1()
{
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account`
ADD `session_handle` char(255) NULL AFTER `refresh_token`,
ADD `expire_session` datetime NOT NULL DEFAULT "2016-01-01 00:00:00"'
);
return true;
}

View File

@@ -0,0 +1,26 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_1_12()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
if (!XAllegroConfiguration::get('ORDER_CUSTOMER_MESSAGE_CONTACT')) {
$contacts = Contact::getContacts(Context::getContext()->language->id);
if (!empty($contacts) && isset($contacts[0]['id_contact'])) {
XAllegroConfiguration::updateValue('ORDER_CUSTOMER_MESSAGE_CONTACT', $contacts[0]['id_contact']);
}
}
return true;
}

View File

@@ -0,0 +1,63 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_1_5()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
XAllegroConfiguration::updateValue('IMAGES_MAIN_TYPE', XAllegroConfiguration::get('IMAGES_TYPE'));
if (Db::getInstance()->getValue('
SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = "' . _DB_NAME_ . '"
AND table_name = "' . _DB_PREFIX_ . 'xallegro_auction"
AND column_name = "id_allegro_account"'
)) {
$xExists = Db::getInstance()->getValue('
SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = "' . _DB_NAME_ . '"
AND table_name = "' . _DB_PREFIX_ . 'xallegro_auction"
AND column_name = "id_xallegro_account"'
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_auction`
SET `id_xallegro_account` = `id_allegro_account`'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`' .
(!$xExists ? 'ADD `id_xallegro_account` int(10) unsigned NOT NULL AFTER `id_xallegro_auction`,' : '') . '
DROP INDEX `id_allegro_account`,
DROP PRIMARY KEY,
DROP `id_allegro_account`,
ADD PRIMARY KEY (`id_xallegro_auction`, `id_xallegro_account`)'
);
}
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_form`
ADD `id_xallegro_account` int(10) unsigned NOT NULL AFTER `id_allegro_form`'
);
$sp = XAllegroConfiguration::get('PAYU_STATUS_SELECTED');
Db::getInstance()->execute('
INSERT IGNORE INTO `' . _DB_PREFIX_ . 'xallegro_status` (`id_order_state`, `id_allegro_state`, `allegro_name`, `position`)
VALUES
(' . $sp . ', "tt", "PayU - Karta kredytowa", 0),
(' . $sp . ', "ap", "Android Pay", 0)'
);
return true;
}

View File

@@ -0,0 +1,28 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_1_7()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
foreach (array(
'PRICE_BASE' => 0,
'ORDER_SEND_MAIL' => 0,
'QUANITY_ALLEGRO_OOS' => 0
) as $key => $value
) {
XAllegroConfiguration::updateValue($key, $value);
}
return true;
}

View File

@@ -0,0 +1,41 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_4_1_8()
{
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_form`
DROP INDEX id_allegro_form'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_template`
ADD `additional_images` char(255) NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_product`
ADD `images` text NULL,
ADD UNIQUE KEY (`id_product`, `id_product_attribute`)'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_pas`
MODIFY `invoice` int(10) unsigned NOT NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_form`
ADD UNIQUE KEY (`id_allegro_form`, `id_xallegro_account`)'
);
return true;
}

View File

@@ -0,0 +1,21 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_4_1_9($module)
{
// directory for template images
if (!is_dir(X13_ALLEGRO_IMG_TEMPLATE)) {
mkdir(X13_ALLEGRO_IMG_TEMPLATE, 0775, true);
}
return true;
}

View File

@@ -0,0 +1,386 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once(dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Api\XAllegroApi;
use x13allegro\Api\XAllegroApiTools;
use x13allegro\Adapter\DbAdapter;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_5_0_0($module)
{
$dbCharset = DbAdapter::getUtf8Collation();
// generate new class_index
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
// START shipments - migration -------------------------------------------------------------------------------------
$oldShipmentsExists = (int)Db::getInstance()->getValue('
SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = "' . _DB_NAME_ . '"
AND table_name = "' . _DB_PREFIX_ . 'xallegro__sell_form_fields"'
);
if ($oldShipmentsExists) {
$fidsDb = Db::getInstance()->executeS('
SELECT `sell_form_id`, `sell_form_field_desc`
FROM `' . _DB_PREFIX_ . 'xallegro__sell_form_fields`
WHERE `sell_form_id` > 35
AND `sell_form_id` < 136
AND `sandbox` = 0'
);
}
if ($oldShipmentsExists && !empty($fidsDb)) {
$shipments = Db::getInstance()->executeS('
SELECT `id_xallegro_pas`, `shipments`
FROM `' . _DB_PREFIX_ . 'xallegro_pas`'
);
$fidsDb = Db::getInstance()->executeS('
SELECT `sell_form_id`, `sell_form_field_desc`
FROM `' . _DB_PREFIX_ . 'xallegro__sell_form_fields`
WHERE `sell_form_id` > 35
AND `sell_form_id` < 136
AND `sandbox` = 0'
);
$fids = array();
foreach ($fidsDb as $fid) {
$fids[$fid['sell_form_id']] = $fid['sell_form_field_desc'];
}
foreach ($shipments as $shipment) {
$shipmentData = unserialize($shipment['shipments']);
$shipmentNew = array();
foreach ($shipmentData as $fidId => $data) {
if ($fidId == 35) {
foreach ($data as $fidOption) {
$shipmentNew[35 . '_' . $fidOption] = array(
'enabled' => $fidOption
);
}
}
if (isset($fids[$fidId])) {
$shipmentNew[$fids[$fidId]] = $data;
}
}
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_pas`
SET `shipments` = "' . pSQL(json_encode($shipmentNew)) . '"
WHERE `id_xallegro_pas` = ' . (int)$shipment['id_xallegro_pas']
);
}
}
// END shipments - migration ---------------------------------------------------------------------------------------
// START category fields - migration -------------------------------------------------------------------------------
$categoryFields = Db::getInstance()->executeS('
SELECT `id_xallegro_category`, `fields`
FROM `' . _DB_PREFIX_ . 'xallegro_category`'
);
foreach ($categoryFields as $categoryField) {
if (!XAllegroApiTools::isSerialized($categoryField['fields'])) {
continue;
}
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_category`
SET `fields` = "' . pSQL(json_encode(unserialize($categoryField['fields']))) . '"
WHERE `id_xallegro_category` = ' . (int)$categoryField['id_xallegro_category']
);
}
// END category fields - migration ---------------------------------------------------------------------------------
// START individual product properties - migration -----------------------------------------------------------------
Db::getInstance()->execute(
'
DELETE p1 FROM `' . _DB_PREFIX_ . 'xallegro_product` p1
INNER JOIN `' . _DB_PREFIX_ . 'xallegro_product` p2
WHERE p1.`id_xallegro_product` > p2.`id_xallegro_product`
AND p1.`id_product` = p2.`id_product`
AND p1.`id_product_attribute` = p2.`id_product_attribute`'
);
$products = Db::getInstance()->executeS('
SELECT `id_xallegro_product`, `description`, `images`
FROM `' . _DB_PREFIX_ . 'xallegro_product`'
);
foreach ($products as $product) {
if (!XAllegroApiTools::isSerialized($product['images'])) {
continue;
}
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_product`
SET `images` = "' . pSQL(json_encode(unserialize($product['images']))) . '",
`description` = "' . pSQL(json_encode(array($product['description'], null, null, null))) . '"
WHERE `id_xallegro_product` = ' . (int)$product['id_xallegro_product']
);
}
// END individual product properties - migration -------------------------------------------------------------------
// START template - migration --------------------------------------------------------------------------------------
$templates = Db::getInstance()->executeS('
SELECT `id_xallegro_template`, `additional_images`
FROM `' . _DB_PREFIX_ . 'xallegro_template`'
);
foreach ($templates as $template) {
if (!XAllegroApiTools::isSerialized($template['additional_images'])) {
continue;
}
if ($template['additional_images']) {
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_template`
SET `additional_images` = "' . pSQL(json_encode(unserialize($template['additional_images']))) . '"
WHERE `id_xallegro_template` = ' . (int)$template['id_xallegro_template']
);
}
}
// END template - migration ----------------------------------------------------------------------------------------
// START auction start_time - migration ----------------------------------------------------------------------------
$auctions = Db::getInstance()->executeS('
SELECT `id_xallegro_auction`, `start_time`
FROM `' . _DB_PREFIX_ . 'xallegro_auction`'
);
foreach ($auctions as $auction) {
if ($auction['start_time'] && isAuctionDateStart($auction['start_time'])) {
$date = new DateTime($auction['start_time']);
$date = $date->format('Y-m-d H:i:s');
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_auction`
SET `start_time` = "' . pSQL($date) . '"
WHERE `id_xallegro_auction` = ' . (int)$auction['id_xallegro_auction']
);
}
}
// END auction start_time - migration ------------------------------------------------------------------------------
// START payment statuses - migration (PayU / Przelewy24) ----------------------------------------------------------
$statuses = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'xallegro_status`');
foreach ($statuses as $status) {
if ($status['id_allegro_state'] == 'b') {
$new_name = 'Przelew tradycyjny';
} elseif ($status['position'] == 0) {
$new_name = preg_replace('/^PayU - /', '', $status['allegro_name']);
} else {
$new_name = preg_replace('/^Status PayU/', 'Status Allegro', $status['allegro_name']);
}
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_status`
SET `allegro_name` = "' . pSQL($new_name) . '"
WHERE `id_xallegro_status` = ' . (int)$status['id_xallegro_status']
);
}
// new statuses
$sp = XAllegroConfiguration::get('PAYU_STATUS_SELECTED');
Db::getInstance()->execute('
INSERT IGNORE INTO `' . _DB_PREFIX_ . 'xallegro_status` (`id_order_state`, `id_allegro_state`, `allegro_name`, `position`)
VALUES
(' . $sp . ', "h", "BPH", 0),
(' . $sp . ', "neb", "Nest Bank", 0),
(' . $sp . ', "rap", "Raiffeisen R-Przelew", 0),
(' . $sp . ', "plb", "Plus Bank", 0),
(' . $sp . ', "bpo", "e-transfer Pocztowy24", 0),
(' . $sp . ', "bsp", "Banki Spoldzielcze", 0)'
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_status`
SET `allegro_name` = "Raty"
WHERE `id_allegro_state` = "ai"'
);
$statuses_ids = XAllegroConfiguration::getMultiple(array(
'PAYU_STATUS_INSTALLMENT',
'PAYU_STATUS_SELECTED',
'PAYU_STATUS_AWAITING'
));
foreach ($statuses_ids as $status_id) {
$os = new OrderState($status_id);
if (Validate::isLoadedObject($os)) {
foreach (Language::getLanguages() as $language) {
$os->name[$language['id_lang']] = trim(preg_replace('/PayU$/', '', $os->name[$language['id_lang']]));
}
$os->save();
}
}
// END payment statuses - migration (PayU / Przelewy24) ------------------------------------------------------------
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account`
DROP `password`,
DROP `rest_apikey`,
DROP `web_apikey`,
DROP `verforms`,
CHANGE `session_handle` `session` text NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_product`
ADD `tags` text NULL,
ADD `images_additional` text NULL,
ADD `title_pattern` char(128) NULL,
ADD `sync_price` tinyint(1) NOT NULL DEFAULT 1,
ADD `sync_quantity_allegro` tinyint(1) NOT NULL DEFAULT 1,
MODIFY `id_product_attribute` int(10) unsigned NULL,
CHANGE `images` `images_positions` text NULL,
CHANGE `description` `descriptions_additional` text NULL,
ADD UNIQUE KEY (`id_product`, `id_product_attribute`)'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_category`
DROP `features`,
ADD `fields_mapping` longtext NULL,
ADD `tags` text NULL,
CHANGE `fields` `fields_values` longtext NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_pas`
DROP `shipment_email`,
DROP `customer_pickup`,
DROP `account_number`,
DROP `account_number_second`,
ADD `country` int(10) unsigned NOT NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
DROP `account_number`,
DROP `account_number_second`,
MODIFY `start_time` datetime NULL'
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_manufacturer` (
`id_xallegro_manufacturer` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_manufacturer` int(10) unsigned NOT NULL,
`tags` text NULL,
PRIMARY KEY (`id_xallegro_manufacturer`),
KEY (`id_manufacturer`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_carrier_package_info` (
`id_order_carrier` int(10) unsigned NOT NULL DEFAULT 0,
`id_order` int(10) unsigned NOT NULL DEFAULT 0,
`id_operator` int(10) unsigned NOT NULL DEFAULT 0,
`operator_name` char(32) NULL,
PRIMARY KEY(`id_order_carrier`),
KEY(`id_order_carrier`, `id_order`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro__cats_form_fields` (
`id_category` int(10) unsigned NOT NULL,
`sell_form_id` int(10) unsigned NOT NULL,
`sell_form_title` char(255),
`sell_form_cat` int(10),
`sell_form_type` int(10),
`sell_form_res_type` int(10),
`sell_form_def_value` int(10),
`sell_form_opt` int(10),
`sell_form_pos` int(10),
`sell_form_length` int(10),
`sell_min_value` decimal(10,2),
`sell_max_value` decimal(10,2),
`sell_form_desc` text,
`sell_form_opts_values` text,
`sell_form_field_desc` text,
`sell_form_param_id` int(10) unsigned,
`sell_form_param_values` text,
`sell_form_parent_id` int(10) unsigned,
`sell_form_parent_value` int(10),
`sell_form_unit` char(16),
`sell_form_options` int(10),
PRIMARY KEY(`id_category`, `sell_form_id`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro__sell_form_fields`');
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_account`
SET `expire_session` = "2016-01-01 00:00:00"'
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_pas`
SET `country` = ' . (int)XAllegroApi::COUNTRY_PL
);
// delete unused configuration
foreach (array(
'INPOST_LETTER',
'INPOST_MACHINE',
'INPOST_MACHINE_COD',
'INPOST_CARRIER',
'INPOST_CARRIER_COD',
'SEND_ADDITIONAL_IMAGES'
) as $conf) {
XAllegroConfiguration::deleteByName($conf);
}
// new configuration
foreach (array(
'PRODUCT_ASSOC_CLOSE_DELETED' => 0,
'PRODUCT_ASSOC_CLOSE_UNACTIVE' => 0,
'ORDER_SEND_CUSTOMER_MAIL' => 0,
'PRICE_UPDATE' => 0,
'PRICE_UPDATE_CHUNK' => 100,
'PRICE_UPDATE_OFFSET' => 0,
'FRONT_DISPLAY_LINK' => 0,
'FRONT_DISPLAY_LINK_HOOK' => (version_compare(_PS_VERSION_, '1.7.0.0', '>=') ? 'displayProductAdditionalInfo' : 'displayLeftColumnProduct')
) as $key => $conf) {
XAllegroConfiguration::updateValue($key, $conf);
}
// install demo templates
$isNewTemplate = (int)Db::getInstance()->getValue('
SELECT COUNT(*)
FROM `' . _DB_PREFIX_ . 'xallegro_template`
WHERE `is_new` = 1'
);
if (!$isNewTemplate) {
$module->installDemoTemplates();
}
$module->reinstallMetas();
return true;
}
function isAuctionDateStart($datetime, $format = 'd.m.Y H:i')
{
$d = DateTime::createFromFormat($format, $datetime);
return $d && $d->format($format) == $datetime;
}

View File

@@ -0,0 +1,47 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Api\XAllegroApiTools;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_5_0_1($module)
{
// generate new class_index
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
// new hooks
$module->registerHook('displayHeader');
$module->registerHook('displayLeftColumnProduct');
$module->registerHook('displayRightColumnProduct');
$module->registerHook('displayProductButtons');
$module->registerHook('displayProductAdditionalInfo');
$module->registerHook('displayProductAllegroAuctionLink');
$module->registerHook('displayAdminProductsExtra');
$module->registerHook('displayAdminOrder');
$module->registerHook('displayAdminOrderTabShip');
$module->registerHook('displayAdminOrderContentShip');
$module->registerHook('actionObjectProductDeleteAfter');
$module->registerHook('actionObjectProductUpdateAfter');
$module->registerHook('actionObjectCombinationDeleteAfter');
$module->registerHook('actionObjectManufacturerDeleteAfter');
$module->registerHook('actionProductSave');
$module->registerHook('actionAdminPerformanceControllerAfter');
$module->registerHook('actionClearSf2Cache');
$module->removeOverride('AdminOrdersController');
XAllegroApiTools::rrmdir(_PS_MODULE_DIR_ . 'x13allegro/override/controllers');
$module->reinstallTabs();
return true;
}

View File

@@ -0,0 +1,54 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_5_1_0($module)
{
// generate new class_index
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_carrier`
ADD `id_operator` int(10) NOT NULL DEFAULT -1,
ADD `operator_name` char(32) NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_carrier_package_info`
ADD `tracking_number` char(64) NULL,
ADD `send` tinyint(1) NOT NULL DEFAULT 0,
ADD INDEX (`send`)'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_form`
ADD `id_allegro_shipment` int(10) unsigned NOT NULL AFTER `id_allegro_form`,
ADD INDEX (`id_allegro_shipment`)'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
ADD `price_buy_now` decimal(10,2) NOT NULL AFTER `quantity_start`'
);
foreach (array(
'ORDER_ALLEGRO_SEND_SHIPPING' => 1,
'QUANITY_ALLEGRO_HOOK_SKIP' => 0
) as $key => $conf) {
XAllegroConfiguration::updateValue($key, $conf);
}
$module->reinstallTabs();
return true;
}

View File

@@ -0,0 +1,176 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Api\Adapter\Delivery\DeliveryMethods;
use x13allegro\Api\Adapter\Location\CountryCode;
use x13allegro\Api\Adapter\Location\Province;
use x13allegro\Api\Adapter\Payments\Invoice;
use x13allegro\Api\Adapter\Delivery\HandlingTime;
use x13allegro\Api\Adapter\Publication\Duration;
use x13allegro\Adapter\DbAdapter;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_6_0_0($module)
{
$dbCharset = DbAdapter::getUtf8Collation();
// generate new class_index
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account`
DROP `verkey`,
DROP `vercats`'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_carrier`
DROP PRIMARY KEY,
MODIFY `id_fields_shipment` char(64) NOT NULL,
ADD INDEX(`id_fields_shipment`)'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
DROP `quantity_start`,
DROP `allegro_shop`,
DROP `abroad`,
DROP `invoice`,
DROP `bank_transfer`,
DROP `pas`,
DROP `state`,
DROP `city`,
DROP `zipcode`,
DROP `id_allegro_category`,
DROP `category_fields`,
DROP `item`,
DROP `shipping_cost`,
DROP `shipment`,
DROP `prepare_time`,
DROP `details`,
DROP `default`,
DROP `resume_auction`'
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_delivery` (
`id_xallegro_delivery` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` char(64) NOT NULL,
`city` char(64) NOT NULL,
`country_code` char(2) NOT NULL,
`post_code` char(16) NULL,
`province` char(32) NULL,
`invoice` char(16) NOT NULL,
`handling_time` char(8) NOT NULL,
`additional_info` text NULL,
`default` tinyint(1) NOT NULL,
`active` tinyint(1) NOT NULL,
PRIMARY KEY (`id_xallegro_delivery`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_category` RENAME `' . _DB_PREFIX_ . 'xallegro_category_backup`');
Db::getInstance()->execute('
CREATE TABLE `' . _DB_PREFIX_ . 'xallegro_category` (
`id_xallegro_category` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_allegro_category` int(10) unsigned NULL,
`id_categories` char(255) NULL,
`path` char(255) NOT NULL,
`fields_values` longtext NULL,
`fields_mapping` longtext NULL,
`tags` text NULL,
PRIMARY KEY (`id_xallegro_category`),
KEY (`id_allegro_category`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
// START carriers - migration --------------------------------------------------------------------------------------
$carriers = Db::getInstance()->executeS('
SELECT `id_fields_shipment` FROM `' . _DB_PREFIX_ . 'xallegro_carrier`'
);
if ($carriers) {
foreach ($carriers as $carrier) {
$newId = DeliveryMethods::map($carrier['id_fields_shipment']);
if ($newId) {
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_carrier`
SET `id_fields_shipment` = "' . pSQL($newId) . '"
WHERE `id_fields_shipment` = ' . (int)$carrier['id_fields_shipment']
);
}
}
}
// END carriers - migration ----------------------------------------------------------------------------------------
// START pas - migration --------------------------------------------------------------------------------------
$profiles = Db::getInstance()->executeS('
SELECT * FROM `' . _DB_PREFIX_ . 'xallegro_pas`'
);
if ($profiles) {
foreach ($profiles as $profile) {
$countryCode = CountryCode::map((int)$profile['country']);
$handlingTime = HandlingTime::map((int)$profile['prepare_time']);
$province = Province::map((int)$profile['state']);
$invoice = Invoice::map((int)$profile['invoice']);
$pas = new XAllegroPas();
$pas->name = $profile['name'];
$pas->city = $profile['city'];
$pas->country_code = ($countryCode ? $countryCode : 'PL');
$pas->post_code = $profile['zipcode'];
$pas->province = ($province ? $province : 0);
$pas->invoice = ($invoice ? $invoice : 0);
$pas->handling_time = ($handlingTime ? $handlingTime : 0);
$pas->additional_info = $profile['details'];
$pas->default = $profile['default'];
$pas->active = $profile['active'];
$pas->save();
}
}
// END pas - migration ----------------------------------------------------------------------------------------
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro_pas`');
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro__cats_list`');
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'xallegro__cats_form_fields`');
Db::getInstance()->execute('TRUNCATE `' . _DB_PREFIX_ . 'xallegro_category`');
XAllegroConfiguration::updateValue('DURATION_DEFAULT', Duration::map((int)XAllegroConfiguration::get('DURATION_DEFAULT')));
$collection = new PrestaShopCollection('XAllegroAccount');
$accounts = $collection->getResults();
if ($accounts) {
/** @var XAllegroAccount $account */
foreach ($accounts as $account) {
$account->client_id = '*';
$account->client_secret = '*';
$account->access_token = null;
$account->refresh_token = null;
$account->session = [];
$account->expire_authorization = '0000-00-00 00:00:00';
$account->expire_refresh = '0000-00-00 00:00:00';
$account->expire_session = '0000-00-00 00:00:00';
$account->save();
}
}
$module->reinstallTabs();
return true;
}

View File

@@ -0,0 +1,42 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Api\Adapter\Delivery\DeliveryMethods;
/**
* @return bool
*/
function upgrade_module_6_0_1()
{
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_form`
MODIFY `id_allegro_shipment` char(64) NOT NULL'
);
// START form - migration ------------------------------------------------------------------------------------------
$forms = Db::getInstance()->executeS('
SELECT `id_xallegro_form`, `id_allegro_shipment`
FROM `' . _DB_PREFIX_ . 'xallegro_form`'
);
if ($forms) {
foreach ($forms as $form) {
$newId = DeliveryMethods::map($form['id_allegro_shipment']);
if ($newId) {
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_form`
SET `id_allegro_shipment` = "' . pSQL($newId) . '"
WHERE `id_xallegro_form` = ' . (int)$form['id_xallegro_form']
);
}
}
}
// END form - migration --------------------------------------------------------------------------------------------
return true;
}

View File

@@ -0,0 +1,15 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_0_2()
{
return true;
}

View File

@@ -0,0 +1,22 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_0_5()
{
// generate new class_index
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
XAllegroConfiguration::updateValue('SYNC_LAST_TIME', date('Y-m-d H:i:s'));
return true;
}

View File

@@ -0,0 +1,21 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_6_0_7($module)
{
// generate new class_index
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
return true;
}

View File

@@ -0,0 +1,22 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_6_0_8($module)
{
if (XAllegroCategory::exists()) {
XAllegroConfiguration::updateValue('PARAMETERS_MIGRATED', 0);
} else {
XAllegroConfiguration::updateValue('PARAMETERS_MIGRATED', 1);
}
return true;
}

View File

@@ -0,0 +1,21 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_1_0()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_category` ADD `name` CHAR(128) AFTER `id_categories`');
return true;
}

View File

@@ -0,0 +1,29 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_1_3()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_form` ADD `id_transaction` CHAR(16)');
if ((int) XAllegroConfiguration::get('PRICE_UPDATE_CHUNK') < 200) {
XAllegroConfiguration::updateValue('PRICE_UPDATE_CHUNK', 200);
}
if ((int) XAllegroConfiguration::get('QUANITY_ALLEGRO_UPDATE_CHUNK') < 200) {
XAllegroConfiguration::updateValue('QUANITY_ALLEGRO_UPDATE_CHUNK', 200);
}
return true;
}

View File

@@ -0,0 +1,49 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_1_4()
{
$deviceColumnsExists = Db::getInstance()->executeS('
SELECT COUNT(*) as `count`
FROM information_schema.columns
WHERE table_schema = "' . _DB_NAME_ . '"
AND table_name = "' . _DB_PREFIX_ . 'xallegro_account"
AND column_name = "device_code"'
);
$alter = [];
if (isset($deviceColumnsExists[0]) && !(int)$deviceColumnsExists[0]['count']) {
$alter[] = 'ADD `device_code` char(64) NULL AFTER `refresh_token`';
$alter[] = 'ADD `user_code` char(64) NULL AFTER `refresh_token`';
}
if (!empty($alter)) {
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account` ' . implode(',', $alter));
}
// resetujemy autoryzacje
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_account`
SET `access_token` = "",
`refresh_token` = "",
`expire_refresh` = "2016-01-01 00:00:00",
`expire_authorization` = "2016-01-01 00:00:00"'
);
// wylaczamy tymczasowo sandboxy
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_account`
SET `active` = 0
WHERE `sandbox` = 1'
);
return true;
}

View File

@@ -0,0 +1,189 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Api\Adapter\Delivery\CarrierOperators;
use x13allegro\SyncManager\Order\Data\Model\OrderMessage;
use x13allegro\Adapter\DbAdapter;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_6_2_0($module)
{
$dbCharset = DbAdapter::getUtf8Collation();
// generate new class_index
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_customer_address` (
`id_xallegro_customer_address` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_customer` int(10) unsigned NOT NULL,
`id_address` int(10) unsigned NOT NULL,
`hash` char(64) NOT NULL,
PRIMARY KEY (`id_xallegro_customer_address`),
UNIQUE KEY (`id_xallegro_customer_address`, `id_customer`, `id_address`),
INDEX (`hash`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_order` (
`id_xallegro_order` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_xallegro_account` int(10) unsigned NOT NULL,
`id_order` int(10) unsigned NULL,
`delivery_method` char(64) NOT NULL,
`checkout_form` char(64) NOT NULL,
`checkout_form_content` text NULL,
`event_type` char(32) NOT NULL,
`occurred_at` char(32) NOT NULL,
`webapi` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id_xallegro_order`),
UNIQUE KEY (`id_xallegro_order`, `id_xallegro_account`),
INDEX (`delivery_method`),
INDEX (`checkout_form`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_order_item` (
`id_xallegro_order` int(10) unsigned NOT NULL,
`line_item` char(64) NOT NULL,
UNIQUE KEY (`id_xallegro_order`, `line_item`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_order_status` (
`allegro_status` char(32) NULL,
`id_order_state` int(10) unsigned NULL,
INDEX(`allegro_status`),
INDEX(`id_order_state`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_delivery_rate` (
`id_xallegro_delivery_rate` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_xallegro_account` int(10) unsigned NOT NULL,
`shipping_rate` char(64) NOT NULL,
`position` int(10) unsigned NOT NULL,
`default` tinyint(1) NOT NULL,
`active` tinyint(1) NOT NULL,
PRIMARY KEY (`id_xallegro_delivery_rate`),
UNIQUE KEY (`id_xallegro_delivery_rate`, `id_xallegro_account`),
INDEX (`shipping_rate`),
INDEX (`position`),
INDEX (`default`),
INDEX (`active`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ .'xallegro_account`
DROP `last_point`,
DROP `last_deals_point`,
DROP `session`,
DROP `expire_session`,
ADD `last_offer_event` char(32) NULL,
ADD `last_order_event` char(32) NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ .'xallegro_carrier`
CHANGE `id_operator` `id_operator` char(32) NULL'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ .'xallegro_carrier_package_info`
CHANGE `id_operator` `id_operator` char(32) NULL'
);
Db::getInstance()->execute('CREATE TABLE `' . _DB_PREFIX_ . 'xallegro_form_backup` LIKE `' . _DB_PREFIX_ . 'xallegro_form`');
Db::getInstance()->execute('INSERT `' . _DB_PREFIX_ . 'xallegro_form_backup` SELECT * FROM `' . _DB_PREFIX_ . 'xallegro_form`');
$authColumnExists = Db::getInstance()->executeS('
SELECT COUNT(*) as `count`
FROM information_schema.columns
WHERE table_schema = "' . _DB_NAME_ . '"
AND table_name = "' . _DB_PREFIX_ . 'xallegro_account"
AND column_name = "expire_authorization"'
);
if (isset($authColumnExists[0]) && !(int)$authColumnExists[0]['count']) {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account`
ADD `expire_authorization` datetime NOT NULL DEFAULT "2016-01-01 00:00:00"'
);
}
$carriers = Db::getInstance()->executeS('
SELECT `id_fields_shipment`, `id_operator`
FROM `' . _DB_PREFIX_ . 'xallegro_carrier`'
);
if ($carriers) {
foreach ($carriers as $carrier) {
$newId = CarrierOperators::map($carrier['id_operator']);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_carrier`
SET `id_operator` = "' . pSQL($newId) . '"
WHERE `id_fields_shipment` = "' . pSQL($carrier['id_fields_shipment']) . '"'
);
}
}
$carriersInfo = Db::getInstance()->executeS('
SELECT `id_order_carrier`, `id_operator`
FROM `' . _DB_PREFIX_ . 'xallegro_carrier_package_info`'
);
if ($carriersInfo) {
foreach ($carriersInfo as $carrierInfo) {
$newId = CarrierOperators::map($carrierInfo['id_operator']);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_carrier_package_info`
SET `id_operator` = "' . pSQL($newId) . '"
WHERE `id_order_carrier` = "' . pSQL($carrierInfo['id_order_carrier']) . '"'
);
}
}
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_state`
SET `deleted` = 1
WHERE `id_order_state` IN (' . implode(',', [
XAllegroConfiguration::get('PAYU_STATUS_INSTALLMENT'),
XAllegroConfiguration::get('PAYU_STATUS_SELECTED'),
XAllegroConfiguration::get('PAYU_STATUS_AWAITING'),
XAllegroConfiguration::get('ALLEGRO_STATUS_SENDIT'),
XAllegroConfiguration::get('ALLEGRO_STATUS_UNSET')
]) .')'
);
XAllegroConfiguration::updateValue('ORDER_MESSAGE_CONFIGURATION', json_encode([OrderMessage::BUYER_MESSAGE => true]));
XAllegroConfiguration::updateValue('ORDER_IMPORT_UNASSOC_PRODUCTS', 1);
XAllegroConfiguration::updateValue('ORDER_IMPORT_UNASSOC_SUMMARY', 1);
if ((int)XAllegroConfiguration::get('IMPORT_ORDERS_CHUNK') < 50) {
XAllegroConfiguration::updateValue('IMPORT_ORDERS_CHUNK', 50);
}
$module->reinstallTabs();
$module->registerHook('displayAdminOrderLeft');
return true;
}

View File

@@ -0,0 +1,26 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_2_4()
{
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ .'xallegro_product`
CHANGE `sync_price` `sync_price` tinyint(1) NOT NULL DEFAULT 4'
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ .'xallegro_product`
SET `sync_price` = 4
WHERE `sync_price` = 1'
);
return true;
}

View File

@@ -0,0 +1,33 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_3_0()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
if (!is_dir(_PS_MODULE_DIR_ . 'x13allegro/cache/json')) {
mkdir(_PS_MODULE_DIR_ . 'x13allegro/cache/json', 0775, true);
}
if (!is_dir(_PS_MODULE_DIR_ . 'x13allegro/backups')) {
mkdir(_PS_MODULE_DIR_ . 'x13allegro/backups', 0775, true);
}
if (!is_dir(_PS_MODULE_DIR_ . 'x13allegro/backups/auctions')) {
mkdir(_PS_MODULE_DIR_ . 'x13allegro/backups/auctions', 0775, true);
}
XAllegroConfiguration::updateValue('PRICE_TAX', 1);
return true;
}

View File

@@ -0,0 +1,72 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_6_3_2($module)
{
$hooksToRegister = [
'displayAdminOrderMain',
'actionGetAdminOrdersButton',
'displayAdminOrderTabLink',
'displayAdminOrderTabContent',
'displayOrderPreview',
'actionDispatcher'
];
foreach ($hooksToRegister as $hook) {
$module->registerHook($hook);
}
$dbCharset = DbAdapter::getUtf8Collation();
if ($dbCharset == 'utf8mb4') {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_template` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_product` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
);
}
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_order`
ADD `fulfillment_status` char(32) NOT NULL AFTER `delivery_method`,
ADD INDEX(`fulfillment_status`)'
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_order_status_fulfillment` (
`allegro_status` char(32) NULL,
`id_order_state` int(10) unsigned NULL,
INDEX (`allegro_status`),
INDEX (`id_order_state`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
$hasIndex = Db::getInstance()->executeS('show index from `'._DB_PREFIX_.'xallegro_carrier_package_info` where Key_name="id_order"');
$nbRows = Db::getInstance()->getValue('SELECT count(`id_order_carrier`) AS `nbResults` FROM `'._DB_PREFIX_.'xallegro_carrier_package_info`');
if (!$hasIndex && $nbRows < 25000) {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ .'xallegro_carrier_package_info`
ADD INDEX(`id_order`)'
);
}
// new override in this version
$module->addOverride('OrderHistory');
return true;
}

View File

@@ -0,0 +1,33 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_6_4_0($module)
{
$dbCharset = DbAdapter::getUtf8Collation();
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_custom_price` (
`id_xallegro_account` int(10) unsigned NOT NULL DEFAULT 0,
`id_product` int(10) unsigned NOT NULL,
`id_product_attribute` int(10) unsigned NOT NULL DEFAULT 0,
`value` DECIMAL(20, 6) NOT NULL,
`method` ENUM("price", "amount", "percentage") NOT NULL DEFAULT "price",
INDEX (`id_xallegro_account`, `id_product`, `id_product_attribute`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
$module->reinstallTabs();
return true;
}

View File

@@ -0,0 +1,48 @@
<?php
use x13allegro\Adapter\DbAdapter;
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_5_0()
{
$dbCharset = DbAdapter::getUtf8Collation();
// generate new class_index
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_template`
MODIFY `additional_images` text NULL'
);
Db::getInstance()->execute('
ALTER TABLE `'._DB_PREFIX_.'xallegro_category`
MODIFY `id_categories` text NULL'
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'xallegro_configuration_account` (
`id_xallegro_configuration_account` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` char(32) NOT NULL,
`value` text NOT NULL,
`id_account` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_xallegro_configuration_account`),
UNIQUE KEY (`name`, `id_account`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
XAllegroConfiguration::updateValue('CLOSE_AUCTION_TRESHOLD', '0');
return true;
}

View File

@@ -0,0 +1,36 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_6_0()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
ADD `fees` decimal(10,2) NOT NULL DEFAULT 0 AFTER `price_buy_now`'
);
XAllegroConfiguration::updateValue('PRODUCTIZATION_DESCRIPTION', 'prestashop');
XAllegroConfiguration::updateValue('PRODUCTIZATION_IMAGES', 'prestashop');
XAllegroConfiguration::updateValue('PARAMETERS_GLOBAL_CONDITION', 1);
foreach (XAllegroAccount::getAll() as $account) {
$accountConfiguration = new XAllegroConfigurationAccount((int) $account->id);
if (!XAllegroConfiguration::get('AUCTION_CALCULATE_FEES')) {
$accountConfiguration->updateValue('AUCTION_CALCULATE_FEES', XAllegroConfigurationAccount::GLOBAL_OPTION);
}
}
return true;
}

View File

@@ -0,0 +1,27 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_6_7_0()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
foreach (XAllegroAccount::getAll() as $account) {
$accountConfiguration = new XAllegroConfigurationAccount((int) $account->id);
if (!XAllegroConfiguration::get('AUCTION_CHECK_BADGES')) {
$accountConfiguration->updateValue('AUCTION_CHECK_BADGES', XAllegroConfigurationAccount::GLOBAL_OPTION);
}
}
return true;
}

View File

@@ -0,0 +1,93 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
use x13allegro\Repository\ProductCustomRepository;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_6_7_1($module)
{
$dbCharset = DbAdapter::getUtf8Collation();
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
$languageExpected = Language::getIdByIso('PL');
$languages = Language::getLanguages();
if (false !== ($key = array_search($languageExpected, array_column($languages, 'id_lang')))) {
$languageId = (int)$languages[$key]['id_lang'];
} else {
$languageId = (int)Configuration::get('PS_LANG_DEFAULT');
}
XAllegroConfiguration::updateValue('AUCTION_LANGUAGE', $languageId);
XAllegroConfiguration::updateValue('IMAGES_CACHE', 168);
XAllegroConfiguration::updateValue('INACTIVE_PRODUCTS_SKIP', 0);
XAllegroConfiguration::updateValue('ORDER_ALLEGRO_SHIPPING_STATUS', 1);
XAllegroConfiguration::updateValue('REGISTER_CUSTOMER_GROUP', (int)Configuration::get('PS_CUSTOMER_GROUP'));
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_custom_product` (
`id_xallegro_account` int(10) unsigned NOT NULL DEFAULT 0,
`id_product` int(10) unsigned NOT NULL,
`title_pattern` char(128) NULL,
`sync_price` tinyint(1) NULL,
`sync_quantity_allegro` tinyint(1) NULL,
UNIQUE KEY (`id_xallegro_account`, `id_product`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
$productCustomData = Db::getInstance()->executeS('
SELECT
`id_product`,
`title_pattern` as `titlePattern`,
IF(`sync_price` = 4, NULL, `sync_price`) as `syncPrice`,
`sync_quantity_allegro` as `syncQuantityAllegro`,
0 as `id_xallegro_account`
FROM `' . _DB_PREFIX_ . 'xallegro_product`
WHERE `id_product_attribute` = 0'
);
$migrationResult = true;
if ($productCustomData) {
foreach ($productCustomData as $data) {
$migrationResult &= ProductCustomRepository::update((int)$data['id_product'], (int)$data['id_xallegro_account'], array_merge($data, ['prices' => []]));
}
}
if ($migrationResult) {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_product`
DROP `title_pattern`,
DROP `sync_price`,
DROP `sync_quantity_allegro`'
);
}
// new "global-options" in ConfigurationAccount for all Accounts
foreach (XAllegroAccount::getAllIds(false) as $row) {
$config = new XAllegroConfigurationAccount($row['id_xallegro_account']);
$config->updateValue('PRICE_UPDATE', XAllegroConfigurationAccount::GLOBAL_OPTION);
$config->updateValue('QUANITY_ALLEGRO_UPDATE', XAllegroConfigurationAccount::GLOBAL_OPTION);
}
$module->registerHook('actionOrderHistoryAddAfter');
$module->reinstallTabs();
if ($module->removeOverride('OrderHistory')) {
$module->addOverride('OrderHistory');
}
return true;
}

View File

@@ -0,0 +1,64 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
/**
* @return bool
*/
function upgrade_module_7_0_1()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute(
'ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
ADD `selling_mode` ENUM("BUY_NOW", "AUCTION") DEFAULT NULL AFTER `id_product_attribute`'
);
Db::getInstance()->execute(
'ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_carrier_package_info`
ADD `send_enabled` tinyint(1) NOT NULL DEFAULT 1 AFTER `send`,
ADD `error` int(10) unsigned NOT NULL DEFAULT 0 AFTER `send_enabled`'
);
$auctionNbRows = DbAdapter::countTableEntries('xallegro_auction', 'id_xallegro_auction');
if (!DbAdapter::showColumnIndex('xallegro_auction', 'quantity') && $auctionNbRows < 35000) {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
ADD INDEX(`quantity`)'
);
}
if (!DbAdapter::showColumnIndex('xallegro_auction', 'selling_mode') && $auctionNbRows < 35000) {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
ADD INDEX(`selling_mode`)'
);
}
$carrierPackageInfoNbRows = DbAdapter::countTableEntries('xallegro_carrier_package_info', 'id_order_carrier');
if (!DbAdapter::showColumnIndex('xallegro_carrier_package_info', 'send_enabled') && $carrierPackageInfoNbRows < 75000) {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_carrier_package_info`
ADD INDEX(`send_enabled`)'
);
}
if (!DbAdapter::showColumnIndex('xallegro_carrier_package_info', 'error') && $carrierPackageInfoNbRows < 75000) {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_carrier_package_info`
ADD INDEX(`error`)'
);
}
XAllegroConfiguration::updateValue('PRODUCTIZATION_MODE', XAllegroAuction::PRODUCTIZATION_ASSIGN);
return true;
}

View File

@@ -0,0 +1,186 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
use x13allegro\Repository\PrestaShop\ProductAttributeRepository;
use x13allegro\Repository\PrestaShop\ProductFeatureRepository;
use x13allegro\Repository\PrestaShop\ManufacturerRepository;
/**
* @return bool
*/
function upgrade_module_7_1_0()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
XAllegroConfiguration::updateValue('MARKUP_CALCULATION', 'WITHOUT_INDIVIDUAL_PRICE');
XAllegroConfiguration::updateValue('IMAGES_UPLOAD_TYPE', 'CURL');
XAllegroConfiguration::updateValue('AUCTION_DISABLE_ORDER_MESSAGE', 0);
XAllegroConfiguration::updateValue('AUCTION_B2B_ONLY', 0);
XAllegroConfiguration::updateValue('PRODUCTIZATION_SEARCH', json_encode([
'product_name' => [
'search' => (int)XAllegroConfiguration::get('PRODUCTIZATION_SEARCH_BY_NAME'),
'select' => (XAllegroConfiguration::get('PRODUCTIZATION_SEARCH_BY_NAME') ? 'only_single' : 'none')
],
'reference' => [
'search' => 1,
'select' => 'only_single'
],
'GTIN' => [
'search' => 1,
'select' => (XAllegroConfiguration::get('PRODUCTIZATION_MAPPING_FIRST') ? 'always_first' : 'only_single')
],
'MPN' => [
'search' => 1,
'select' => 'only_single'
]
]));
// new "global-options" in ConfigurationAccount for all Accounts
foreach (XAllegroAccount::getAllIds(false) as $row) {
$config = new XAllegroConfigurationAccount($row['id_xallegro_account']);
$config->updateValue('MARKUP_CALCULATION', XAllegroConfigurationAccount::GLOBAL_OPTION);
$config->updateValue('AUCTION_DISABLE_ORDER_MESSAGE', XAllegroConfigurationAccount::GLOBAL_OPTION);
$config->updateValue('AUCTION_B2B_ONLY', XAllegroConfigurationAccount::GLOBAL_OPTION);
}
// "active" DEFAULT 1 on upgrade
Db::getInstance()->execute(
'ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_category`
ADD `active` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `id_categories`,
ADD `fields_ambiguous_values` longtext NULL AFTER `fields_values`'
);
if (!DbAdapter::showColumnIndex('xallegro_category', 'active')) {
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_category`
ADD INDEX(`active`)'
);
}
// copy categories to backup
Db::getInstance()->execute('CREATE TABLE `' . _DB_PREFIX_ . 'xallegro_category_backup710` LIKE `' . _DB_PREFIX_ . 'xallegro_category`');
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'xallegro_category_backup710` SELECT * FROM `' . _DB_PREFIX_ . 'xallegro_category`');
// migrate categories
$dataToMigrate = Db::getInstance()->executeS('
SELECT `id_xallegro_category`, `fields_mapping`
FROM `' . _DB_PREFIX_ . 'xallegro_category_backup710`'
);
if (!empty($dataToMigrate)) {
$languageId = XAllegroConfiguration::get('AUCTION_LANGUAGE');
$repository = [
'attribute_group' => [],
'attribute' => [],
'feature' => [],
'feature_value' => [],
'manufacturer' => []
];
foreach (ProductAttributeRepository::getAllAttributeValues($languageId) as $attributeValue) {
if (!in_array($attributeValue['id_attribute_group'], $repository['attribute_group'])) {
$repository['attribute_group'][] = $attributeValue['id_attribute_group'];
}
$repository['attribute'][] = $attributeValue['id_attribute'];
}
foreach (ProductFeatureRepository::getAllFeatureValues($languageId) as $featureValue) {
if (!in_array($featureValue['id_feature'], $repository['feature'])) {
$repository['feature'][] = $featureValue['id_feature'];
}
$repository['feature_value'][] = $featureValue['id_feature_value'];
}
foreach (ManufacturerRepository::getAll() as $manufacturer) {
$repository['manufacturer'][] = $manufacturer['id_manufacturer'];
}
foreach ($dataToMigrate as $categoryToMigrate) {
$fieldsMappingToMigrate = json_decode($categoryToMigrate['fields_mapping'], true);
$fieldsMapping = [];
foreach ($fieldsMappingToMigrate as $parameterId => $mapping) {
if (!empty($mapping)) {
// select/checkbox/multiple/range
if (is_array($mapping)) {
foreach ($mapping as $valueId => $map) {
$escaped = _migration_escapeParameterMapping($map);
if ($escaped !== false) {
// multiple/range
if (is_int($valueId)) {
if ($escaped['prefix'] == 'product' || in_array($escaped['suffix'], $repository[$escaped['prefix']])) {
$fieldsMapping[$parameterId][] = [
'rule' => $escaped['prefix'],
'ruleValue' => $escaped['suffix']
];
}
}
// select/checkbox
else {
if ($escaped['prefix'] == 'product' || in_array($escaped['suffix'], $repository[$escaped['prefix']])) {
$fieldsMapping[$parameterId][] = [
'valueId' => $valueId,
'rule' => $escaped['prefix'],
'ruleValue' => $escaped['suffix']
];
}
}
}
}
}
// text
else {
$escaped = _migration_escapeParameterMapping($mapping);
if ($escaped !== false) {
if ($escaped['prefix'] == 'product' || in_array($escaped['suffix'], $repository[$escaped['prefix']])) {
$fieldsMapping[$parameterId][] = [
'rule' => $escaped['prefix'],
'ruleValue' => $escaped['suffix']
];
}
}
}
}
}
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_category`
SET `fields_mapping` = "' .pSQL(json_encode($fieldsMapping)) . '"
WHERE `id_xallegro_category` = ' . (int)$categoryToMigrate['id_xallegro_category']
);
}
}
return true;
}
function _migration_escapeParameterMapping($mapping)
{
$pos = strrpos($mapping, '_');
if ($pos !== false) {
$prefix = substr($mapping, 0, $pos);
$suffix = substr($mapping, $pos + 1, strlen($mapping));
if ($suffix == 'ean') {
$suffix = 'ean13';
}
return [
'prefix' => $prefix,
'suffix' => $suffix
];
}
return false;
}

View File

@@ -0,0 +1,25 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_7_1_1($module)
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
XAllegroConfiguration::updateValue('IMAGES_MANUFACTURER_TYPE', '');
XAllegroConfiguration::updateValue('ORDER_ADD_PAYMENT_WHEN_COD', 0);
$module->registerHook('actionOrderStatusUpdate');
return true;
}

View File

@@ -0,0 +1,26 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @return bool
*/
function upgrade_module_7_1_2()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
ADD `archived_date` datetime NULL AFTER `closed`,
ADD `archived` tinyint(1) unsigned NOT NULL DEFAULT 0 AFTER `closed`,
ADD INDEX(`archived`)'
);
return true;
}

View File

@@ -0,0 +1,88 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
use x13allegro\Api\XAllegroApi;
/**
* @return bool
*/
function upgrade_module_7_2_0()
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
$dbCharset = DbAdapter::getUtf8Collation();
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_configuration`
MODIFY `name` char(64)'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_configuration_account`
MODIFY `name` char(64)'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account`
ADD `base_marketplace` char(32) NULL AFTER `sandbox`,
ADD INDEX(`base_marketplace`)'
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_account`
SET `base_marketplace` = "' . pSQL(XAllegroApi::MARKETPLACE_PL) . '"'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_order`
ADD `marketplace` char(32) NOT NULL AFTER `fulfillment_status`,
ADD INDEX(`marketplace`)'
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_order`
SET `marketplace` = "' . pSQL(XAllegroApi::MARKETPLACE_PL) . '"'
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_auction_marketplace` (
`id_auction` bigint(20) NOT NULL,
`marketplace` char(32) NOT NULL,
`price_buy_now` decimal(10,2) NOT NULL DEFAULT "0.00",
`last_status` char(32) NULL,
`last_status_date` datetime NULL,
`last_status_refusal_reasons` text NULL,
PRIMARY KEY (`id_auction`, `marketplace`),
INDEX (`marketplace`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_auction_process` (
`id_xallegro_auction_process` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_xallegro_account` int(10) unsigned NOT NULL,
`id_auction` bigint(20) NOT NULL,
`id_operation` char(64) NOT NULL,
`operation` ENUM("PRICE_UPDATE") NOT NULL,
`date_add` datetime NOT NULL,
PRIMARY KEY (`id_xallegro_auction_process`),
INDEX (`id_xallegro_account`),
INDEX (`id_auction`),
INDEX (`operation`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
XAllegroConfiguration::updateValue('AUCTION_FIELDS_LIST_SETTINGS', json_encode([]));
XAllegroConfiguration::updateValue('AUCTION_MARKETPLACE_CONVERSION_RATE', 'CURRENCY');
XAllegroConfiguration::updateValue('AUCTION_MARKETPLACE_CONVERSION_RATE_VALUE', json_encode([]));
XAllegroConfiguration::updateValue('DELETE_ARCHIVED_OFFERS', 90);
return true;
}

View File

@@ -0,0 +1,169 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
use x13allegro\Adapter\DbAdapter;
use x13allegro\Api\Model\Order\Enum\FulfillmentStatus;
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_7_3_0($module)
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
$dbCharset = DbAdapter::getUtf8Collation();
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_order_status`
RENAME `' . _DB_PREFIX_ . 'xallegro_order_status_backup`'
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_order_status` (
`allegro_status` char(32) NULL,
`marketplace` char(32) NULL,
`id_order_state` int(10) unsigned NULL,
UNIQUE KEY (`allegro_status`, `marketplace`),
INDEX (`allegro_status`),
INDEX (`marketplace`),
INDEX (`id_order_state`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_account`
ADD `id_language` int(10) unsigned NULL AFTER `base_marketplace`,
ADD INDEX(`id_language`)'
);
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'xallegro_account`
SET `id_language` = ' . (int)XAllegroConfiguration::get('AUCTION_LANGUAGE')
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction`
ADD `auto_renew` tinyint(1) NULL AFTER `start_time`,
ADD `end_date` datetime NULL AFTER `archived_date`,
ADD INDEX(`auto_renew`),
ADD INDEX(`end_date`)'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_custom_product`
ADD `auto_renew` tinyint(1) NULL AFTER `sync_quantity_allegro`'
);
Db::getInstance()->execute('
ALTER TABLE `' . _DB_PREFIX_ . 'xallegro_auction_process`
MODIFY `operation` char(255) NOT NULL,
DROP INDEX operation'
);
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'xallegro_log` (
`id_xallegro_log` char(64) NOT NULL,
`id_xallegro_account` int(10) unsigned NULL,
`id_employee` int(10) unsigned NULL,
`id_offer` bigint(20) unsigned NULL,
`id_shop` int(10) unsigned NULL,
`id_product` int(10) unsigned NULL,
`id_product_attribute` int(10) unsigned NULL,
`id_order` int(10) unsigned NULL,
`env` char(64) NOT NULL,
`level` char(64) NOT NULL,
`type` char(64) NOT NULL,
`message` text NULL,
`hash` char(32) NOT NULL,
`counter` int(10) unsigned NOT NULL DEFAULT 1,
`displayed` tinyint(1) unsigned NOT NULL DEFAULT 0,
`send` tinyint(1) unsigned NOT NULL DEFAULT 1,
`last_occurrence` datetime NOT NULL,
PRIMARY KEY (`id_xallegro_log`),
INDEX (`id_xallegro_account`),
INDEX (`id_employee`),
INDEX (`id_shop`),
INDEX (`id_product`),
INDEX (`id_product_attribute`),
INDEX (`id_order`),
INDEX (`env`),
INDEX (`level`),
INDEX (`type`),
UNIQUE INDEX (`hash`, `displayed`),
INDEX (`send`),
INDEX (`last_occurrence`)
) ENGINE=InnoDB DEFAULT CHARSET=' . $dbCharset
);
$statusBackup = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'xallegro_order_status_backup`');
if (!empty($statusBackup)) {
$statusNew = [];
foreach ($statusBackup as $status) {
$statusNew['default'][$status['allegro_status']]['id_order_state'] = $status['id_order_state'];
}
XAllegroStatus::updateStatuses($statusNew, false);
}
$productizationMode = XAllegroConfiguration::get('PRODUCTIZATION_MODE');
if ($productizationMode == XAllegroAuction::PRODUCTIZATION_NONE) {
XAllegroConfiguration::updateValue('PRODUCTIZATION_MODE', XAllegroAuction::PRODUCTIZATION_NEW);
}
$priceUpdateChunk = (int)XAllegroConfiguration::get('PRICE_UPDATE_CHUNK');
$quantityUpdateChunk = (int)XAllegroConfiguration::get('QUANITY_ALLEGRO_UPDATE_CHUNK');
$updateOfferChunk = max($priceUpdateChunk, $quantityUpdateChunk, X13_ALLEGRO_UPDATE_OFFERS_CHUNK);
XAllegroConfiguration::updateValue('UPDATE_OFFERS_CHUNK', $updateOfferChunk);
XAllegroConfiguration::updateValue('PRODUCT_ASSOC_CLOSE_UNACTIVE_DB', 0);
XAllegroConfiguration::updateValue('PRODUCT_ASSOC_CLOSE_SKIP_BID_AUCTION', 0);
XAllegroConfiguration::updateValue('ORDER_STATUS_BY_MARKETPLACE', 0);
XAllegroConfiguration::updateValue('ORDER_IMPORT_UNASSOC_PRODUCTS_EXTERNAL', 0);
XAllegroConfiguration::updateValue('ORDER_ALLEGRO_SHIPPING_STATUS_FULFILLMENT', FulfillmentStatus::SENT()->getKey());
XAllegroConfiguration::updateValue('QUANTITY_AUTO_RENEW', 0);
XAllegroConfiguration::updateValue('QUANTITY_AUTO_RENEW_THRESHOLD', 0);
XAllegroConfiguration::updateValue('PRODUCT_ASSOC_RENEW_ONLY_ACTIVE', 1);
XAllegroConfiguration::updateValue('PRODUCT_ASSOC_RENEW_ACTIVE', 0);
XAllegroConfiguration::updateValue('PRODUCT_ASSOC_RENEW_ACTIVE_DB', 0);
XAllegroConfiguration::updateValue('OFFER_RENEW_KEEP_PROMOTION', 1);
XAllegroConfiguration::updateValue('OFFER_RENEW_MAX_DAYS', 0);
XAllegroConfiguration::updateValue('LOG_SEND', 0);
XAllegroConfiguration::updateValue('LOG_SEND_LEVEL', json_encode([]));
XAllegroConfiguration::updateValue('LOG_SEND_EMAIL_LIST', json_encode([]));
// new "global-options" in ConfigurationAccount for all Accounts
foreach (XAllegroAccount::getAllIds(false) as $row) {
$config = new XAllegroConfigurationAccount($row['id_xallegro_account']);
$config->updateValue('QUANTITY_AUTO_RENEW', XAllegroConfigurationAccount::GLOBAL_OPTION);
$config->updateValue('OFFER_RENEW_KEEP_PROMOTION', XAllegroConfigurationAccount::GLOBAL_OPTION);
}
$module->reinstallTabs();
$emptyProductId = (int)XAllegroConfiguration::get('EMPTY_PRODUCT_ID');
if ($emptyProductId) {
$productFieldsNotNull = [];
if (version_compare(_PS_VERSION_, '1.7.0.0', '>=')) {
$productFieldsNotNull['isbn'] = '';
}
if (version_compare(_PS_VERSION_, '1.7.7.0', '>=')) {
$productFieldsNotNull['mpn'] = '';
}
Db::getInstance()->update('product', array_merge($productFieldsNotNull, [
'ean13' => '',
'upc' => ''
]), 'id_product = ' . $emptyProductId);
}
return true;
}

View File

@@ -0,0 +1,36 @@
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
require_once (dirname(__FILE__) . '/../x13allegro.php');
/**
* @param $module x13allegro
* @return bool
*/
function upgrade_module_7_4_0($module)
{
XAllegroAutoLoader::getInstance()
->generateClassIndex()
->autoload();
XAllegroConfiguration::updateValue('AUCTION_PRICE_CUSTOMER_GROUP', Configuration::get('PS_UNIDENTIFIED_GROUP'));
XAllegroConfiguration::updateValue('PRODUCTIZATION_NAME', 'prestashop');
XAllegroConfiguration::updateValue('REGISTER_CUSTOMER_GROUP_DEFAULT', XAllegroConfiguration::get('REGISTER_CUSTOMER_GROUP'));
XAllegroConfiguration::updateValue('REGISTER_CUSTOMER_GROUP', json_encode([XAllegroConfiguration::get('REGISTER_CUSTOMER_GROUP') => true]));
// new "global-options" in ConfigurationAccount for all Accounts
foreach (XAllegroAccount::getAllIds(false) as $row) {
$config = new XAllegroConfigurationAccount($row['id_xallegro_account']);
$config->updateValue('AUCTION_PRICE_CUSTOMER_GROUP', XAllegroConfigurationAccount::GLOBAL_OPTION);
}
$module->registerHook('actionSetInvoice');
$module->registerHook('actionX13AllegroOrderInvoiceList');
$module->registerHook('actionX13AllegroOrderInvoiceUpload');
$module->registerHook('actionObjectGroupDeleteAfter');
return true;
}