// import csv ok for group attribute position

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8693 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vChabot committed 2011-09-21 14:38:12 +00:00
1 parent 8b6ec916e0
commit 46ba33ef92
5 files changed
+33 -17

No files matched your search

+25 -10
View File
@@ -80,11 +80,13 @@ class AdminImport extends AdminTab
switch ((int)(Tools::getValue('entity'))) switch ((int)(Tools::getValue('entity')))
{ {
case $this->entities[$this->l('Combinations')]: case $this->entities[$this->l('Combinations')]:
self::$required_fields = array('id_product', 'options'); self::$required_fields = array('id_product', 'group', 'attribute');
$this->available_fields = array( $this->available_fields = array(
'no' => array('label' => $this->l('Ignore this column')), 'no' => array('label' => $this->l('Ignore this column')),
'id_product' => array('label' => $this->l('Product ID').'*'), 'id_product' => array('label' => $this->l('Product ID').'*'),
'options' => array('label' => $this->l('Options (Group:Value:Position)').'*', 'group' => array('label' => $this->l('Group (Name:Position)').'*',
'help' => $this->l('Position of the group attribute.')),
'attribute' => array('label' => $this->l('Attribute (Value:Position)').'*',
'help' => $this->l('Position of the attribute in the attribute group.')), 'help' => $this->l('Position of the attribute in the attribute group.')),
'reference' => array('label' => $this->l('Reference')), 'reference' => array('label' => $this->l('Reference')),
'supplier_reference' => array('label' => $this->l('Supplier reference')), 'supplier_reference' => array('label' => $this->l('Supplier reference')),
@@ -971,13 +973,15 @@ class AdminImport extends AdminTab
$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($info['ecotax']), (int)($info['quantity']), $id_image, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int)($info['default_on']), strval($info['upc'])); $id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($info['ecotax']), (int)($info['quantity']), $id_image, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int)($info['default_on']), strval($info['upc']));
$id_attribute_group = 0; $id_attribute_group = 0;
foreach (explode($fsep, $info['options']) as $option) $group = '';
foreach (explode($fsep, $info['group']) as $group)
{ {
$options = explode(':', $option); $tab_group = explode(':', $group);
list($group, $attribute) = array_map('trim', $options); $group = $tab_group[0];
$id_attribute_group = $groups[$group];
// if position is filled // if position is filled
if (isset($options[2])) if (isset($tab_group[1]))
$position = $options[2]; $position = $tab_group[1];
else else
$position = false; $position = false;
if (!isset($groups[$group])) if (!isset($groups[$group]))
@@ -986,6 +990,7 @@ class AdminImport extends AdminTab
$obj->is_color_group = false; $obj->is_color_group = false;
$obj->name[$defaultLanguage] = $group; $obj->name[$defaultLanguage] = $group;
$obj->public_name[$defaultLanguage] = $group; $obj->public_name[$defaultLanguage] = $group;
$obj->position = (!$position) ? AttributeGroup::getHigherPosition() + 1 : $position;
if (($fieldError = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true AND ($langFieldError = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) if (($fieldError = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true AND ($langFieldError = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
{ {
$obj->add(); $obj->add();
@@ -994,7 +999,16 @@ class AdminImport extends AdminTab
else else
$this->_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : ''); $this->_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : '');
} }
$id_attribute_group = $groups[$group]; }
foreach (explode($fsep, $info['attribute']) as $attribute)
{
$tab_attribute = explode(':', $attribute);
$attribute = $tab_attribute[0];
// if position is filled
if (isset($tab_attribute[1]))
$position = $tab_attribute[1];
else
$position = false;
if (!isset($attributes[$group.'_'.$attribute])) if (!isset($attributes[$group.'_'.$attribute]))
{ {
$obj = new Attribute(); $obj = new Attribute();
@@ -1010,14 +1024,15 @@ class AdminImport extends AdminTab
$this->_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : ''); $this->_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : '');
} }
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'product_attribute_combination (id_attribute, id_product_attribute) VALUES ('.(int)($attributes[$group.'_'.$attribute]).','.(int)$id_product_attribute.')');
} }
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'product_attribute_combination (id_attribute, id_product_attribute) VALUES ('.(int)($attributes[$group.'_'.$attribute]).','.(int)$id_product_attribute.')');
} }
$this->closeCsvFile($handle); $this->closeCsvFile($handle);
// after insertion, we clean attribute position // after insertion, we clean attribute position and group attribute position
$obj = new Attribute(); $obj = new Attribute();
$obj->cleanPositions((int)$id_attribute_group, false); $obj->cleanPositions((int)$id_attribute_group, false);
AttributeGroup::cleanPositions();
} }
public function customerImport() public function customerImport()
+3 -2
View File
@@ -5,6 +5,7 @@
'Address' => 'override/classes/Address.php', 'Address' => 'override/classes/Address.php',
'AddressFormatCore' => 'classes/AddressFormat.php', 'AddressFormatCore' => 'classes/AddressFormat.php',
'AddressFormat' => 'override/classes/AddressFormat.php', 'AddressFormat' => 'override/classes/AddressFormat.php',
'AdminController' => 'classes/AdminController.php',
'AdminTabCore' => 'classes/AdminTab.php', 'AdminTabCore' => 'classes/AdminTab.php',
'AdminTab' => 'override/classes/AdminTab.php', 'AdminTab' => 'override/classes/AdminTab.php',
'AliasCore' => 'classes/Alias.php', 'AliasCore' => 'classes/Alias.php',
@@ -251,9 +252,9 @@
'DbMySQLiCore' => 'classes/db/DbMySQLi.php', 'DbMySQLiCore' => 'classes/db/DbMySQLi.php',
'DbMySQLi' => 'override/classes/db/DbMySQLi.php', 'DbMySQLi' => 'override/classes/db/DbMySQLi.php',
'DbPDOCore' => 'classes/db/DbPDO.php', 'DbPDOCore' => 'classes/db/DbPDO.php',
'DbPDO' => 'override/classes/db/DbPDO.php', 'DbPDO' => '',
'DbQueryCore' => 'classes/db/DbQuery.php', 'DbQueryCore' => 'classes/db/DbQuery.php',
'DbQuery' => 'override/classes/db/DbQuery.php', 'DbQuery' => '',
'MySQLCore' => 'classes/db/MySQL.php', 'MySQLCore' => 'classes/db/MySQL.php',
'MySQL' => 'override/classes/db/MySQL.php', 'MySQL' => 'override/classes/db/MySQL.php',
'GroupShopCore' => 'classes/shop/GroupShop.php', 'GroupShopCore' => 'classes/shop/GroupShop.php',
+1 -1
View File
@@ -285,7 +285,7 @@ INSERT INTO `PREFIX_category_lang` (`id_category`, `id_lang`, `name`, `descripti
INSERT INTO `PREFIX_category_product` (`id_category`, `id_product`, `position`) VALUES INSERT INTO `PREFIX_category_product` (`id_category`, `id_product`, `position`) VALUES
(1, 1, 0),(1, 2, 1),(1, 6, 2),(1, 7, 3),(2, 1, 0),(2, 2, 1),(2, 7, 2),(3, 8, 0),(3, 9, 1),(4, 5, 0),(4, 6, 1); (1, 1, 0),(1, 2, 1),(1, 6, 2),(1, 7, 3),(2, 1, 0),(2, 2, 1),(2, 7, 2),(3, 8, 0),(3, 9, 1),(4, 5, 0),(4, 6, 1);
INSERT INTO `PREFIX_attribute_group` (`id_attribute_group`, `is_color_group`) VALUES (1, 0, 'select'),(2, 1, 'color'),(3, 0, 'select'); INSERT INTO `PREFIX_attribute_group` (`id_attribute_group`, `is_color_group`, `position`) VALUES (1, 0, 0),(2, 1, 1),(3, 0, 2);
INSERT INTO `PREFIX_attribute_group_group_shop` (`id_attribute_group`, `id_group_shop`) (SELECT `id_attribute_group`, 1 FROM `PREFIX_attribute_group`); INSERT INTO `PREFIX_attribute_group_group_shop` (`id_attribute_group`, `id_group_shop`) (SELECT `id_attribute_group`, 1 FROM `PREFIX_attribute_group`);
INSERT INTO `PREFIX_attribute_group_lang` (`id_attribute_group`, `id_lang`, `name`, `public_name`) VALUES INSERT INTO `PREFIX_attribute_group_lang` (`id_attribute_group`, `id_lang`, `name`, `public_name`) VALUES
(1, 1, 'Disk space', 'Disk space'),(1, 2, 'Capacité', 'Capacité'),(2, 1, 'Color', 'Color'),(2, 2, 'Couleur', 'Couleur'),(3, 1, 'ICU', 'Processor'), (1, 1, 'Disk space', 'Disk space'),(1, 2, 'Capacité', 'Capacité'),(2, 1, 'Color', 'Color'),(2, 2, 'Couleur', 'Couleur'),(3, 1, 'ICU', 'Processor'),
+1 -3
View File
@@ -150,6 +150,4 @@ ALTER TABLE `PREFIX_product_download` ADD `is_shareable` TINYINT( 1 ) UNSIGNED N
ALTER TABLE `PREFIX_attribute_group` ADD `position` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'; ALTER TABLE `PREFIX_attribute_group` ADD `position` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE `PREFIX_attribute_group` ADD `group_type` ENUM('select', 'radio', 'color') NOT NULL DEFAULT 'select'; /* PHP:add_group_attribute_position(); */;
UPDATE `PREFIX_attribute_group` SET `group_type`='color' WHERE `is_color_group` = 1;
ALTER TABLE `PREFIX_product` DROP `id_color_default`;
+3 -1
View File
@@ -1191,7 +1191,9 @@ $_LANGADM['AdminImport2377be3c2ad9b435ba277a73f0f1ca76'] = 'Fabricants';
$_LANGADM['AdminImport1814d65a76028fdfbadab64a5a8076df'] = 'Fournisseurs'; $_LANGADM['AdminImport1814d65a76028fdfbadab64a5a8076df'] = 'Fournisseurs';
$_LANGADM['AdminImportb8495b50f5c172ebad1cc5c615548afa'] = 'Ignorer cette colonne'; $_LANGADM['AdminImportb8495b50f5c172ebad1cc5c615548afa'] = 'Ignorer cette colonne';
$_LANGADM['AdminImport97f08a40f22a625d0cbfe03db3349108'] = 'ID produit'; $_LANGADM['AdminImport97f08a40f22a625d0cbfe03db3349108'] = 'ID produit';
$_LANGADM['AdminImport9608f36da60f49e9d5e203916de5f6e9'] = 'Options (Groupe:Valeur:Position)'; $_LANGADM['AdminImportabaebb382cb5980ac3a28e6b7634801f'] = 'Groupe (Nom:Position)';
$_LANGADM['AdminImport71a336d5333641c567b41a0ea59edb4f'] = 'Position du groupe d\'attribut.';
$_LANGADM['AdminImport17c9395a749ecae6dfa95e1c899c81ba'] = 'Attribut (Valeur:Position)';
$_LANGADM['AdminImport6ea61efe688b5afde35e1b11517d0e56'] = 'Position de l\'attribut dans le groupe d\'attribut.'; $_LANGADM['AdminImport6ea61efe688b5afde35e1b11517d0e56'] = 'Position de l\'attribut dans le groupe d\'attribut.';
$_LANGADM['AdminImport63d5049791d9d79d86e9a108b0a999ca'] = 'Référence'; $_LANGADM['AdminImport63d5049791d9d79d86e9a108b0a999ca'] = 'Référence';
$_LANGADM['AdminImport8284ae5df53e6e7ffc1f2cc67ae68765'] = 'Référence fournisseur'; $_LANGADM['AdminImport8284ae5df53e6e7ffc1f2cc67ae68765'] = 'Référence fournisseur';