Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap
Conflicts: admin-dev/themes/default/template/controllers/carrier_wizard/helpers/form/form_ranges.tpl admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl admin-dev/themes/default/template/controllers/modules/filters.tpl admin-dev/themes/default/template/controllers/modules/list.tpl admin-dev/themes/default/template/controllers/orders/form.tpl admin-dev/themes/default/template/helpers/form/form.tpl classes/Category.php classes/controller/AdminController.php controllers/admin/AdminAttributesGroupsController.php controllers/admin/AdminFeaturesController.php controllers/admin/AdminImportController.php controllers/admin/AdminLogsController.php install-dev/install_version.php install-dev/langs/ru/data/tab.xml js/admin_carrier_wizard.js modules/loyalty/loyalty.php
This commit is contained in:
@@ -220,8 +220,16 @@ class AdminImportControllerCore extends AdminController
|
||||
'ean13' => array('label' => $this->l('EAN13')),
|
||||
'upc' => array('label' => $this->l('UPC')),
|
||||
'ecotax' => array('label' => $this->l('Ecotax')),
|
||||
'width' => array('label' => $this->l('Width')),
|
||||
'height' => array('label' => $this->l('Height')),
|
||||
'depth' => array('label' => $this->l('Depth')),
|
||||
'weight' => array('label' => $this->l('Weight')),
|
||||
'quantity' => array('label' => $this->l('Quantity')),
|
||||
'minimal_quantity' => array('label' => $this->l('Minimal quantity')),
|
||||
'visibility' => array('label' => $this->l('Visibility')),
|
||||
'additional_shipping_cost' => array('label' => $this->l('Additional shipping cost')),
|
||||
'unity' => array('label' => $this->l('Unity')),
|
||||
'unit_price_ratio' => array('label' => $this->l('Unit price ratio')),
|
||||
'description_short' => array('label' => $this->l('Short description')),
|
||||
'description' => array('label' => $this->l('Description')),
|
||||
'tags' => array('label' => $this->l('Tags (x,y,z...)')),
|
||||
@@ -232,6 +240,7 @@ class AdminImportControllerCore extends AdminController
|
||||
'available_now' => array('label' => $this->l('Text when in stock')),
|
||||
'available_later' => array('label' => $this->l('Text when backorder allowed')),
|
||||
'available_for_order' => array('label' => $this->l('Available for order (0 = No, 1 = Yes)')),
|
||||
'available_date' => array('label' => $this->l('Product available date')),
|
||||
'date_add' => array('label' => $this->l('Product creation date')),
|
||||
'show_price' => array('label' => $this->l('Show price (0 = No, 1 = Yes)')),
|
||||
'image' => array('label' => $this->l('Image URLs (x,y,z...)')),
|
||||
@@ -241,6 +250,11 @@ class AdminImportControllerCore extends AdminController
|
||||
'features' => array('label' => $this->l('Feature(Name:Value:Position)')),
|
||||
'online_only' => array('label' => $this->l('Available online only (0 = No, 1 = Yes)')),
|
||||
'condition' => array('label' => $this->l('Condition')),
|
||||
'customizable' => array('label' => $this->l('Customizable (0 = No, 1 = Yes)')),
|
||||
'uploadable_files' => array('label' => $this->l('Uploadable files (0 = No, 1 = Yes)')),
|
||||
'text_fields' => array('label' => $this->l('Text fields (0 = No, 1 = Yes)')),
|
||||
'out_of_stock' => array('label' => $this->l('Out_of_stock')),
|
||||
'advanced_stock_management' => array('label' => $this->l('Advanced stock management')),
|
||||
'shop' => array(
|
||||
'label' => $this->l('ID / Name of shop'),
|
||||
'help' => $this->l('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.'),
|
||||
@@ -251,15 +265,28 @@ class AdminImportControllerCore extends AdminController
|
||||
'id_category' => array((int)Configuration::get('PS_HOME_CATEGORY')),
|
||||
'id_category_default' => (int)Configuration::get('PS_HOME_CATEGORY'),
|
||||
'active' => '1',
|
||||
'width' => 0.000000,
|
||||
'height' => 0.000000,
|
||||
'depth' => 0.000000,
|
||||
'weight' => 0.000000,
|
||||
'visibility' => 'both',
|
||||
'additional_shipping_cost' => 0.00,
|
||||
'unit_price_ratio' => 0.000000,
|
||||
'quantity' => 0,
|
||||
'minimal_quantity' => 1,
|
||||
'price' => 0,
|
||||
'id_tax_rules_group' => 0,
|
||||
'description_short' => array((int)Configuration::get('PS_LANG_DEFAULT') => ''),
|
||||
'link_rewrite' => array((int)Configuration::get('PS_LANG_DEFAULT') => ''),
|
||||
'online_only' => 0,
|
||||
'condition' => 'new',
|
||||
'available_date' => date('Y-m-d'),
|
||||
'date_add' => date('Y-m-d H:i:s'),
|
||||
'condition' => 'new',
|
||||
'customizable' => 0,
|
||||
'uploadable_files' => 0,
|
||||
'text_fields' => 0,
|
||||
'out_of_stock' => '2',
|
||||
'advanced_stock_management' => '0',
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -279,6 +306,7 @@ class AdminImportControllerCore extends AdminController
|
||||
'firstname' => array('label' => $this->l('First Name *')),
|
||||
'newsletter' => array('label' => $this->l('Newsletter (0/1)')),
|
||||
'optin' => array('label' => $this->l('Opt-in (0/1)')),
|
||||
'group' => array('label' => $this->l('Groupe Name')),
|
||||
'id_shop' => array(
|
||||
'label' => $this->l('ID / Name of shop'),
|
||||
'help' => $this->l('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.'),
|
||||
@@ -294,6 +322,7 @@ class AdminImportControllerCore extends AdminController
|
||||
case $this->entities[$this->l('Addresses')]:
|
||||
//Overwrite required_fields
|
||||
$this->required_fields = array(
|
||||
'alias',
|
||||
'lastname',
|
||||
'firstname',
|
||||
'address1',
|
||||
@@ -308,7 +337,7 @@ class AdminImportControllerCore extends AdminController
|
||||
'id' => array('label' => $this->l('ID')),
|
||||
'alias' => array('label' => $this->l('Alias *')),
|
||||
'active' => array('label' => $this->l('Active (0/1)')),
|
||||
'customer_email' => array('label' => $this->l('Customer email')),
|
||||
'customer_email' => array('label' => $this->l('Customer email *')),
|
||||
'id_customer' => array('label' => $this->l('Customer ID:')),
|
||||
'manufacturer' => array('label' => $this->l('Manufacturer')),
|
||||
'supplier' => array('label' => $this->l('Supplier')),
|
||||
@@ -317,7 +346,7 @@ class AdminImportControllerCore extends AdminController
|
||||
'firstname' => array('label' => $this->l('First Name *')),
|
||||
'address1' => array('label' => $this->l('Address 1 *')),
|
||||
'address2' => array('label' => $this->l('Address 2')),
|
||||
'postcode' => array('label' => $this->l('Postal code / Zipcode*')),
|
||||
'postcode' => array('label' => $this->l('Postal code / Zipcode *')),
|
||||
'city' => array('label' => $this->l('City *')),
|
||||
'country' => array('label' => $this->l('Country *')),
|
||||
'state' => array('label' => $this->l('State')),
|
||||
@@ -427,12 +456,8 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
}
|
||||
|
||||
$this->separator = strval(trim(Tools::getValue('separator', ';')));
|
||||
|
||||
if (is_null(Tools::getValue('multiple_value_separator')) || trim(Tools::getValue('multiple_value_separator')) == '')
|
||||
$this->multiple_value_separator = ',';
|
||||
else
|
||||
$this->multiple_value_separator = Tools::getValue('multiple_value_separator');
|
||||
$this->separator = substr(strval(trim(Tools::getValue('separator', ';'))), 0, 1);
|
||||
$this->multiple_value_separator = substr(strval(trim(Tools::getValue('multiple_value_separator', ','))), 0, 1);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -470,14 +495,26 @@ class AdminImportControllerCore extends AdminController
|
||||
if (isset($this->entities[$this->l(Tools::ucfirst(Tools::getValue('import_type')))]))
|
||||
{
|
||||
$entity_selected = $this->entities[$this->l(Tools::ucfirst(Tools::getValue('import_type')))];
|
||||
$this->context->cookie->entity_selected = $entity_selected;
|
||||
$this->context->cookie->entity_selected = (int)$entity_selected;
|
||||
}
|
||||
elseif (isset($this->context->cookie->entity_selected))
|
||||
$entity_selected = (int)$this->context->cookie->entity_selected;
|
||||
|
||||
|
||||
$csv_selected = '';
|
||||
if (isset($this->context->cookie->csv_selected))
|
||||
$csv_selected = pSQL($this->context->cookie->csv_selected);
|
||||
$csv_selected = base64_decode($this->context->cookie->csv_selected);
|
||||
|
||||
$id_lang_selected = '';
|
||||
if (isset($this->context->cookie->iso_lang_selected) && $this->context->cookie->iso_lang_selected)
|
||||
$id_lang_selected = (int)Language::getIdByIso(base64_decode($this->context->cookie->iso_lang_selected));
|
||||
|
||||
$separator_selected = $this->multiple_value_separator;
|
||||
if (isset($this->context->cookie->separator_selected) && $this->context->cookie->separator_selected)
|
||||
$separator_selected = base64_decode($this->context->cookie->separator_selected);
|
||||
|
||||
$multiple_value_separator_selected = $this->separator;
|
||||
if (isset($this->context->cookie->multiple_value_separator_selected) && $this->context->cookie->multiple_value_separator_selected)
|
||||
$multiple_value_separator_selected = base64_decode($this->context->cookie->multiple_value_separator_selected);
|
||||
|
||||
$this->tpl_form_vars = array(
|
||||
'module_confirmation' => (Tools::getValue('import')) && (isset($this->warnings) && !count($this->warnings)),
|
||||
@@ -485,9 +522,11 @@ class AdminImportControllerCore extends AdminController
|
||||
'entities' => $this->entities,
|
||||
'entity_selected' => $entity_selected,
|
||||
'csv_selected' => $csv_selected,
|
||||
'separator_selected' => $separator_selected,
|
||||
'multiple_value_separator_selected' => $multiple_value_separator_selected,
|
||||
'files_to_import' => $files_to_import,
|
||||
'languages' => Language::getLanguages(false),
|
||||
'id_language' => $this->context->language->id,
|
||||
'id_language' => ($id_lang_selected) ? $id_lang_selected : $this->context->language->id,
|
||||
'available_fields' => $this->getAvailableFields(),
|
||||
'truncateAuthorized' => (Shop::isFeatureActive() && $this->context->employee->isSuperAdmin()) || !Shop::isFeatureActive(),
|
||||
'PS_ADVANCED_STOCK_MANAGEMENT' => Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'),
|
||||
@@ -512,10 +551,11 @@ class AdminImportControllerCore extends AdminController
|
||||
for ($i = 0; $i < $nb_table; $i++)
|
||||
$data[$i] = $this->generateContentTable($i, $nb_column, $handle, $this->separator);
|
||||
|
||||
if ($entity_selected = (int)Tools::getValue('entity'))
|
||||
$this->context->cookie->entity_selected = $entity_selected;
|
||||
if ($csv_selected = Tools::getValue('csv'))
|
||||
$this->context->cookie->csv_selected = $csv_selected;
|
||||
$this->context->cookie->entity_selected = (int)Tools::getValue('entity');
|
||||
$this->context->cookie->iso_lang_selected = base64_encode(Tools::getValue('iso_lang'));
|
||||
$this->context->cookie->separator_selected = base64_encode(Tools::getValue('separator'));
|
||||
$this->context->cookie->multiple_value_separator_selected = base64_encode(Tools::getValue('multiple_value_separator'));
|
||||
$this->context->cookie->csv_selected = base64_encode(Tools::getValue('csv'));
|
||||
|
||||
$this->tpl_view_vars = array(
|
||||
'import_matchs' => Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'import_match'),
|
||||
@@ -574,18 +614,13 @@ class AdminImportControllerCore extends AdminController
|
||||
// Header
|
||||
for ($i = 0; $i < $nb_column; $i++)
|
||||
if (MAX_COLUMNS * (int)$current_table <= $i && (int)$i < MAX_COLUMNS * ((int)$current_table + 1))
|
||||
$html .= '<th width:"'.(900 / MAX_COLUMNS).'" valign="top">
|
||||
<select onchange="askFeatureName(this, '.$i.');"
|
||||
style="width: '.(900 / MAX_COLUMNS).'px;"
|
||||
$html .= '<th style="width: '.(900 / MAX_COLUMNS).'px; vertical-align: top; padding: 4px">
|
||||
<select style="width: '.(900 / MAX_COLUMNS).'px;"
|
||||
id="type_value['.$i.']"
|
||||
name="type_value['.$i.']"
|
||||
class="type_value">
|
||||
'.$this->getTypeValuesOptions($i).'
|
||||
</select>
|
||||
<div id="features_'.$i.'" style="display: none;">
|
||||
<input style="width: 90px" type="text" name="" id="feature_name_'.$i.'">
|
||||
<input type="button" value="ok" onclick="replaceFeature($(\'#feature_name_'.$i.'\').attr(\'name\'), '.$i.');">
|
||||
</div>
|
||||
</th>';
|
||||
$html .= '</tr>';
|
||||
|
||||
@@ -675,7 +710,8 @@ class AdminImportControllerCore extends AdminController
|
||||
$fd = fopen($uniqid_path, 'r');
|
||||
$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);
|
||||
fclose($fd);
|
||||
unlink($uniqid_path);
|
||||
if (file_exists($uniqid_path))
|
||||
@unlink($uniqid_path);
|
||||
}
|
||||
|
||||
if (empty($tab) || (!is_array($tab)))
|
||||
@@ -873,6 +909,9 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->receiveTab();
|
||||
$handle = $this->openCsvFile();
|
||||
$default_language_id = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
|
||||
if (!Validate::isUnsignedId($id_lang))
|
||||
$id_lang = $default_language_id;
|
||||
AdminImportController::setLocale();
|
||||
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
|
||||
{
|
||||
@@ -919,8 +958,8 @@ class AdminImportControllerCore extends AdminController
|
||||
$category_to_create = new Category();
|
||||
$category_to_create->name = AdminImportController::createMultiLangField($category->parent);
|
||||
$category_to_create->active = 1;
|
||||
$category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]);
|
||||
$category_to_create->link_rewrite = $category_link_rewrite;
|
||||
$category_link_rewrite = Tools::link_rewrite($category_to_create->name[$id_lang]);
|
||||
$category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite);
|
||||
$category_to_create->id_parent = Configuration::get('PS_HOME_CATEGORY'); // Default parent is home for unknown category to create
|
||||
if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
||||
($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $category_to_create->add())
|
||||
@@ -930,7 +969,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$category_to_create->name[$default_language_id],
|
||||
(isset($category_to_create->id) ? $category_to_create->id : 'null')
|
||||
(isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -963,7 +1002,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->warnings[] = sprintf(
|
||||
Tools::displayError('Rewrite link for %1$s (ID: %2$s) was re-written as %3$s.'),
|
||||
$bak,
|
||||
(isset($info['id']) ? $info['id'] : 'null'),
|
||||
(isset($info['id']) && !empty($info['id']))? $info['id'] : 'null',
|
||||
$category->link_rewrite[$default_language_id]
|
||||
);
|
||||
$res = false;
|
||||
@@ -1011,8 +1050,8 @@ class AdminImportControllerCore extends AdminController
|
||||
{
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
|
||||
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
|
||||
(isset($info['name']) && !empty($info['name']))? Tools::safeOutput($info['name']) : 'No Name',
|
||||
(isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID'
|
||||
);
|
||||
$error_tmp = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError();
|
||||
if ($error_tmp != '')
|
||||
@@ -1056,6 +1095,9 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->receiveTab();
|
||||
$handle = $this->openCsvFile();
|
||||
$default_language_id = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
|
||||
if (!Validate::isUnsignedId($id_lang))
|
||||
$id_lang = $default_language_id;
|
||||
AdminImportController::setLocale();
|
||||
$shop_ids = Shop::getCompleteListOfShopsID();
|
||||
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
|
||||
@@ -1066,13 +1108,23 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
if (Tools::getValue('forceIDs') && isset($info['id']) && (int)$info['id'])
|
||||
$product = new Product((int)$info['id']);
|
||||
else
|
||||
elseif (Tools::getValue('match_ref') && array_key_exists('reference', $info))
|
||||
{
|
||||
if (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product'))
|
||||
$product = new Product((int)$info['id']);
|
||||
else
|
||||
$product = new Product();
|
||||
$datas = Db::getInstance()->getRow('
|
||||
SELECT p.`id_product`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.`reference` = "'.pSQL($info['reference']).'"
|
||||
');
|
||||
if (isset($datas['id_product']) && $datas['id_product'])
|
||||
$product = new Product((int)$datas['id_product']);
|
||||
else
|
||||
$product = new Product();
|
||||
}
|
||||
elseif (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product'))
|
||||
$product = new Product((int)$info['id']);
|
||||
else
|
||||
$product = new Product();
|
||||
|
||||
if (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product'))
|
||||
{
|
||||
@@ -1137,7 +1189,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$manufacturer->name,
|
||||
(isset($manufacturer->id) ? $manufacturer->id : 'null')
|
||||
(isset($manufacturer->id) && !empty($manufacturer->id))? $manufacturer->id : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -1168,7 +1220,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$supplier->name,
|
||||
(isset($supplier->id) ? $supplier->id : 'null')
|
||||
(isset($supplier->id) && !empty($supplier->id))? $supplier->id : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -1214,7 +1266,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$category_to_create->name[$default_language_id],
|
||||
(isset($category_to_create->id) ? $category_to_create->id : 'null')
|
||||
(isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -1246,7 +1298,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$category_to_create->name[$default_language_id],
|
||||
(isset($category_to_create->id) ? $category_to_create->id : 'null')
|
||||
(isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -1257,14 +1309,14 @@ class AdminImportControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$product->id_category_default = isset($product->id_category[0]) ? (int)$product->id_category[0] : '';
|
||||
|
||||
$link_rewrite = (is_array($product->link_rewrite) && count($product->link_rewrite)) ? trim($product->link_rewrite[$default_language_id]) : '';
|
||||
|
||||
$link_rewrite = (is_array($product->link_rewrite) && isset($product->link_rewrite[$id_lang])) ? trim($product->link_rewrite[$id_lang]) : '';
|
||||
|
||||
$valid_link = Validate::isLinkRewrite($link_rewrite);
|
||||
|
||||
if ((isset($product->link_rewrite[$default_language_id]) && empty($product->link_rewrite[$default_language_id])) || !$valid_link)
|
||||
if ((isset($product->link_rewrite[$id_lang]) && empty($product->link_rewrite[$id_lang])) || !$valid_link)
|
||||
{
|
||||
$link_rewrite = Tools::link_rewrite($product->name[$default_language_id]);
|
||||
$link_rewrite = Tools::link_rewrite($product->name[$id_lang]);
|
||||
if ($link_rewrite == '')
|
||||
$link_rewrite = 'friendly-url-autogeneration-failed';
|
||||
}
|
||||
@@ -1272,18 +1324,20 @@ class AdminImportControllerCore extends AdminController
|
||||
if (!$valid_link)
|
||||
$this->warnings[] = sprintf(
|
||||
Tools::displayError('Rewrite link for %1$s (ID: %2$s) was re-written as %3$s.'),
|
||||
$product->name[$default_language_id],
|
||||
(isset($info['id']) ? $info['id'] : 'null'),
|
||||
$product->name[$id_lang],
|
||||
(isset($info['id']) && !empty($info['id']))? $info['id'] : 'null',
|
||||
$link_rewrite
|
||||
);
|
||||
|
||||
$product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite);
|
||||
if (!Tools::getValue('match_ref') || !(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang])))
|
||||
$product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite);
|
||||
|
||||
// replace the value of separator by coma
|
||||
if ($this->multiple_value_separator != ',')
|
||||
foreach ($product->meta_keywords as &$meta_keyword)
|
||||
if (!empty($meta_keyword))
|
||||
$meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword);
|
||||
if (is_array($product->meta_keywords))
|
||||
foreach ($product->meta_keywords as &$meta_keyword)
|
||||
if (!empty($meta_keyword))
|
||||
$meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword);
|
||||
|
||||
// Convert comma into dot for all floating values
|
||||
foreach (Product::$definition['fields'] as $key => $array)
|
||||
@@ -1309,7 +1363,7 @@ class AdminImportControllerCore extends AdminController
|
||||
SELECT product_shop.`date_add`, p.`id_product`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.`reference` = "'.$product->reference.'"
|
||||
WHERE p.`reference` = "'.pSQL($product->reference).'"
|
||||
');
|
||||
$product->id = (int)$datas['id_product'];
|
||||
$product->date_add = pSQL($datas['date_add']);
|
||||
@@ -1355,8 +1409,8 @@ class AdminImportControllerCore extends AdminController
|
||||
{
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
|
||||
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
|
||||
(isset($info['name']) && !empty($info['name']))? Tools::safeOutput($info['name']) : 'No Name',
|
||||
(isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -1365,7 +1419,7 @@ class AdminImportControllerCore extends AdminController
|
||||
else
|
||||
{
|
||||
// Product supplier
|
||||
if (isset($product->id_supplier) && isset($product->supplier_reference))
|
||||
if (isset($product->id_supplier) && property_exists($product, 'supplier_reference'))
|
||||
{
|
||||
$id_product_supplier = ProductSupplier::getIdByProductAndSupplier((int)$product->id, 0, (int)$product->id_supplier);
|
||||
if ($id_product_supplier)
|
||||
@@ -1382,31 +1436,67 @@ class AdminImportControllerCore extends AdminController
|
||||
}
|
||||
|
||||
// SpecificPrice (only the basic reduction feature is supported by the import)
|
||||
if ((isset($info['reduction_price']) && $info['reduction_price'] > 0) || (isset($info['reduction_percent']) && $info['reduction_percent'] > 0))
|
||||
{
|
||||
$specific_price = new SpecificPrice();
|
||||
$specific_price->id_product = (int)$product->id;
|
||||
// @todo multishop specific price import
|
||||
$specific_price->id_shop = $this->context->shop->id;
|
||||
$specific_price->id_currency = 0;
|
||||
$specific_price->id_country = 0;
|
||||
$specific_price->id_group = 0;
|
||||
$specific_price->price = -1;
|
||||
$specific_price->id_customer = 0;
|
||||
$specific_price->from_quantity = 1;
|
||||
$specific_price->reduction = (isset($info['reduction_price']) && $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100;
|
||||
$specific_price->reduction_type = (isset($info['reduction_price']) && $info['reduction_price']) ? 'amount' : 'percentage';
|
||||
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
|
||||
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
|
||||
if (!$specific_price->add())
|
||||
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
|
||||
}
|
||||
if (!Shop::isFeatureActive())
|
||||
$info['shop'] = 1;
|
||||
elseif (!isset($info['shop']) || empty($info['shop']))
|
||||
$info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
|
||||
|
||||
// Get shops for each attributes
|
||||
$info['shop'] = explode($this->multiple_value_separator, $info['shop']);
|
||||
|
||||
$id_shop_list = array();
|
||||
foreach ($info['shop'] as $shop)
|
||||
if (!is_numeric($shop))
|
||||
$id_shop_list[] = (int)Shop::getIdByName($shop);
|
||||
else
|
||||
$id_shop_list[] = $shop;
|
||||
|
||||
if ((isset($info['reduction_price']) && $info['reduction_price'] > 0) || (isset($info['reduction_percent']) && $info['reduction_percent'] > 0))
|
||||
foreach($id_shop_list as $id_shop)
|
||||
{
|
||||
$specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
|
||||
|
||||
if (is_array($specific_price) && isset($specific_price['id_specific_price']))
|
||||
$specific_price = new SpecificPrice((int)$specific_price['id_specific_price']);
|
||||
else
|
||||
$specific_price = new SpecificPrice();
|
||||
$specific_price->id_product = (int)$product->id;
|
||||
$specific_price->id_specific_price_rule = 0;
|
||||
$specific_price->id_shop = $id_shop;
|
||||
$specific_price->id_currency = 0;
|
||||
$specific_price->id_country = 0;
|
||||
$specific_price->id_group = 0;
|
||||
$specific_price->price = -1;
|
||||
$specific_price->id_customer = 0;
|
||||
$specific_price->from_quantity = 1;
|
||||
$specific_price->reduction = (isset($info['reduction_price']) && $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100;
|
||||
$specific_price->reduction_type = (isset($info['reduction_price']) && $info['reduction_price']) ? 'amount' : 'percentage';
|
||||
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
|
||||
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
|
||||
if (!$specific_price->save())
|
||||
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
|
||||
}
|
||||
|
||||
if (isset($product->tags) && !empty($product->tags))
|
||||
{
|
||||
if (isset($product->id) && $product->id)
|
||||
{
|
||||
$tags = Tag::getProductTags($product->id);
|
||||
if (is_array($tags) && count($tags))
|
||||
{
|
||||
if (!empty($product->tags))
|
||||
$product->tags = explode($this->multiple_value_separator, $product->tags);
|
||||
if (is_array($product->tags) && count($product->tags))
|
||||
{
|
||||
foreach ($product->tags as $key => $tag)
|
||||
$product->tags[$key] = trim($tag);
|
||||
$tags[$id_lang] = $product->tags;
|
||||
$product->tags = $tags;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Delete tags for this id product, for no duplicating error
|
||||
Tag::deleteTagsForProduct($product->id);
|
||||
|
||||
if (!is_array($product->tags))
|
||||
{
|
||||
$product->tags = AdminImportController::createMultiLangField($product->tags);
|
||||
@@ -1498,7 +1588,7 @@ class AdminImportControllerCore extends AdminController
|
||||
if(!empty($feature_name) && !empty($feature_value))
|
||||
{
|
||||
$id_feature = Feature::addFeatureImport($feature_name, $position);
|
||||
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value);
|
||||
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value, $product->id, $id_lang);
|
||||
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
|
||||
}
|
||||
}
|
||||
@@ -1759,8 +1849,9 @@ class AdminImportControllerCore extends AdminController
|
||||
null,
|
||||
$id_shop_list
|
||||
);
|
||||
|
||||
$id_product_attribute_update = true;
|
||||
if (isset($info['supplier_reference']) && !empty($info['supplier_reference']))
|
||||
$product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1786,8 +1877,10 @@ class AdminImportControllerCore extends AdminController
|
||||
(int)$info['minimal_quantity'],
|
||||
$id_shop_list
|
||||
);
|
||||
if (isset($info['supplier_reference']) && !empty($info['supplier_reference']))
|
||||
$product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']);
|
||||
}
|
||||
|
||||
|
||||
// fills our attributes array, in order to add the attributes to the product_attribute afterwards
|
||||
if(isset($attributes[$group.'_'.$attribute]))
|
||||
$attributes_to_add[] = (int)$attributes[$group.'_'.$attribute];
|
||||
@@ -1831,6 +1924,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$customer_exist = false;
|
||||
$this->receiveTab();
|
||||
$handle = $this->openCsvFile();
|
||||
$default_language_id = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
AdminImportController::setLocale();
|
||||
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
|
||||
{
|
||||
@@ -1863,6 +1957,26 @@ class AdminImportControllerCore extends AdminController
|
||||
unset($customer_groups[$key]);
|
||||
}
|
||||
|
||||
// Group Importation
|
||||
if (isset($info['group']) && !empty($info['group']))
|
||||
{
|
||||
if (!isset($customer_groups))
|
||||
$customer_groups = array();
|
||||
|
||||
$myGroup = Group::searchByName($default_language_id, $info['group']);
|
||||
|
||||
if (!$myGroup)
|
||||
{
|
||||
$myGroup = new Group();
|
||||
$myGroup->name = Array($default_language_id => $info['group']);
|
||||
$myGroup->price_display_method = 1;
|
||||
$myGroup->add();
|
||||
$myGroup = Group::searchByName($default_language_id, $info['group']);
|
||||
}
|
||||
if (isset($myGroup['0']['id_group']))
|
||||
$customer_groups[] = $myGroup['0']['id_group'];
|
||||
}
|
||||
|
||||
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
|
||||
|
||||
if ($customer->passwd)
|
||||
@@ -1962,7 +2076,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$info['email'],
|
||||
(isset($info['id']) ? $info['id'] : 'null')
|
||||
(isset($info['id']) && !empty($info['id']))? $info['id'] : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -2059,7 +2173,7 @@ class AdminImportControllerCore extends AdminController
|
||||
Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s) cannot be saved'),
|
||||
Db::getInstance()->getMsgError(),
|
||||
$address->customer_email,
|
||||
(isset($info['id']) ? $info['id'] : 'null')
|
||||
(isset($info['id']) && !empty($info['id']))? $info['id'] : 'null'
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2108,7 +2222,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$manufacturer->name,
|
||||
(isset($manufacturer->id) ? $manufacturer->id : 'null')
|
||||
(isset($manufacturer->id) && !empty($manufacturer->id))? $manufacturer->id : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -2129,7 +2243,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$supplier->name,
|
||||
(isset($supplier->id) ? $supplier->id : 'null')
|
||||
(isset($supplier->id) && !empty($supplier->id))? $supplier->id : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -2158,7 +2272,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$info['alias'],
|
||||
(isset($info['id']) ? $info['id'] : 'null')
|
||||
(isset($info['id']) && !empty($info['id']))? $info['id'] : 'null'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2175,7 +2289,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$info['alias'],
|
||||
(isset($info['id']) ? $info['id'] : 'null')
|
||||
(isset($info['id']) && !empty($info['id']))? $info['id'] : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -2245,8 +2359,8 @@ class AdminImportControllerCore extends AdminController
|
||||
{
|
||||
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
|
||||
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
|
||||
(isset($info['name']) && !empty($info['name']))? Tools::safeOutput($info['name']) : 'No Name',
|
||||
(isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
Db::getInstance()->getMsgError();
|
||||
@@ -2292,8 +2406,8 @@ class AdminImportControllerCore extends AdminController
|
||||
if (!$res)
|
||||
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
|
||||
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
|
||||
(isset($info['name']) && !empty($info['name']))? Tools::safeOutput($info['name']) : 'No Name',
|
||||
(isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID'
|
||||
);
|
||||
else
|
||||
{
|
||||
@@ -2551,13 +2665,9 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
protected static function usortFiles($a, $b)
|
||||
{
|
||||
$a = strrev(substr(strrev($a), 0, 14));
|
||||
$b = strrev(substr(strrev($b), 0, 14));
|
||||
|
||||
if ($a == $b)
|
||||
return 0;
|
||||
|
||||
return ($a < $b) ? 1 : -1;
|
||||
return ($b < $a) ? 1 : -1;
|
||||
}
|
||||
|
||||
protected function openCsvFile()
|
||||
@@ -2602,37 +2712,37 @@ class AdminImportControllerCore extends AdminController
|
||||
unlink(_PS_CAT_IMG_DIR_.$d);
|
||||
break;
|
||||
case $this->entities[$this->l('Products')]:
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_shop');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'feature_product');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_lang');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'category_product');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_tag');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'image');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'image_lang');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'image_shop');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'specific_price');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'specific_price_priority');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_carrier');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'cart_product');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'compare_product');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_shop`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'feature_product`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_lang`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'category_product`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_tag`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'image`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'image_lang`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'image_shop`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'specific_price`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'specific_price_priority`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_carrier`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'cart_product`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'compare_product`');
|
||||
if (count(Db::getInstance()->executeS('SHOW TABLES LIKE \''._DB_PREFIX_.'favorite_product\' '))) //check if table exist
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'favorite_product');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attachment');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_country_tax');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_download');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_group_reduction_cache');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_sale');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_supplier');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'scene_products');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'warehouse_product_location');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'stock');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'stock_available');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'stock_mvt');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'customization');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'customization_field');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'supply_order_detail');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'attribute_impact');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'favorite_product`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attachment`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_country_tax`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_download`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_group_reduction_cache`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_sale`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_supplier`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'scene_products`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'warehouse_product_location`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'stock`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'stock_available`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'stock_mvt`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'customization`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'customization_field`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'supply_order_detail`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'attribute_impact`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_shop`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_combination`');
|
||||
@@ -2643,7 +2753,7 @@ class AdminImportControllerCore extends AdminController
|
||||
break;
|
||||
case $this->entities[$this->l('Combinations')]:
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'attribute`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'attribute_impact');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'attribute_impact`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'attribute_lang`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'attribute_group`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'attribute_group_lang`');
|
||||
@@ -2653,26 +2763,26 @@ class AdminImportControllerCore extends AdminController
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_shop`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_combination`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_image`');
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'stock_available` WHERE id_product_attribute !=0');
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'stock_available` WHERE id_product_attribute != 0');
|
||||
break;
|
||||
case $this->entities[$this->l('Customers')]:
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'customer');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'customer`');
|
||||
break;
|
||||
case $this->entities[$this->l('Addresses')]:
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'address');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'address`');
|
||||
break;
|
||||
case $this->entities[$this->l('Manufacturers')]:
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'manufacturer');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'manufacturer_lang');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'manufacturer_shop');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'manufacturer`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'manufacturer_lang`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'manufacturer_shop`');
|
||||
foreach (scandir(_PS_MANU_IMG_DIR_) as $d)
|
||||
if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $d))
|
||||
unlink(_PS_MANU_IMG_DIR_.$d);
|
||||
break;
|
||||
case $this->entities[$this->l('Suppliers')]:
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'supplier');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'supplier_lang');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'supplier_shop');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'supplier`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'supplier_lang`');
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'supplier_shop`');
|
||||
foreach (scandir(_PS_SUPP_IMG_DIR_) as $d)
|
||||
if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $d))
|
||||
unlink(_PS_SUPP_IMG_DIR_.$d);
|
||||
@@ -2701,6 +2811,7 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
if (Tools::isSubmit('submitFileUpload'))
|
||||
{
|
||||
$path = _PS_ADMIN_DIR_.'/import/'.date('Ymdhis').'-';
|
||||
if (isset($_FILES['file']) && !empty($_FILES['file']['error']))
|
||||
{
|
||||
switch ($_FILES['file']['error'])
|
||||
@@ -2726,13 +2837,18 @@ class AdminImportControllerCore extends AdminController
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!file_exists($_FILES['file']['tmp_name']) ||
|
||||
!@move_uploaded_file($_FILES['file']['tmp_name'], _PS_ADMIN_DIR_.'/import/'.date('Ymdhis').'-'.$_FILES['file']['name']))
|
||||
elseif (!preg_match('/.*\.csv$/i', $_FILES['file']['name']))
|
||||
$this->errors[] = Tools::displayError('The extension of your file should be .csv.');
|
||||
elseif (!file_exists($_FILES['file']['tmp_name']) ||
|
||||
!@move_uploaded_file($_FILES['file']['tmp_name'], $path.$_FILES['file']['name']))
|
||||
$this->errors[] = $this->l('An error occurred while uploading / copying the file.');
|
||||
else
|
||||
{
|
||||
@chmod($path.$_FILES['file']['name'], 0664);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=18');
|
||||
}
|
||||
}
|
||||
else if (Tools::getValue('import'))
|
||||
elseif (Tools::getValue('import'))
|
||||
{
|
||||
// Check if the CSV file exist
|
||||
if (Tools::getValue('csv'))
|
||||
@@ -2787,16 +2903,50 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
if ($import_type !== false)
|
||||
{
|
||||
$log_message = sprintf($this->l('%s import'), $import_type);
|
||||
$log_message = sprintf($this->l('%s import', 'AdminTab', false, false), $import_type);
|
||||
if (Tools::getValue('truncate'))
|
||||
$log_message .= ' '.$this->l('with truncate');
|
||||
$log_message .= ' '.$this->l('with truncate', 'AdminTab', false, false);
|
||||
Logger::addLog($log_message, 1, null, $import_type, null, true, (int)$this->context->employee->id);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->errors[] = $this->l('You must upload a file in order to proceed to the next step');
|
||||
}
|
||||
|
||||
elseif ($filename = Tools::getValue('csvfilename'))
|
||||
{
|
||||
$filename = base64_decode($filename);
|
||||
$file = _PS_ADMIN_DIR_.'/import/'.basename($filename);
|
||||
if (realpath(dirname($file)) != _PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'import')
|
||||
exit();
|
||||
if (!empty($filename))
|
||||
{
|
||||
$bName = basename($filename);
|
||||
if ($delete = Tools::getValue('delete') && file_exists($file))
|
||||
@unlink($file);
|
||||
elseif (file_exists($file))
|
||||
{
|
||||
$bName = explode('.', $bName);
|
||||
$bName = strtolower($bName[count($bName) - 1]);
|
||||
$mimeTypes = array('csv' => 'text/csv');
|
||||
|
||||
if (isset($mimeTypes[$bName]))
|
||||
$mimeType = $mimeTypes[$bName];
|
||||
else
|
||||
$mimeType = 'application/octet-stream';
|
||||
if (ob_get_level())
|
||||
ob_end_clean();
|
||||
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Content-Type: '.$mimeType);
|
||||
header('Content-Length: '.filesize($file));
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
$fp = fopen($file, 'rb');
|
||||
while (is_resource($fp) && !feof($fp))
|
||||
echo fgets($fp, 16384);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user