// Fix product attributes

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11308 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-12-16 15:06:53 +00:00
parent 5a4bc80867
commit 31f3a71b9d
7 changed files with 81 additions and 51 deletions
+63 -29
View File
@@ -590,11 +590,53 @@ class AdminProductsControllerCore extends AdminController
$this->_errors[] = Tools::displayError('Invalid date format.');
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
// Add new
else
{
if ($this->tabAccess['add'] === '1')
{
if ($product->productAttributeExists($_POST['attribute_combinaison_list']))
$this->_errors[] = Tools::displayError('This combination already exists.');
else
$id_product_attribute = $product->addCombinationEntity(
Tools::getValue('attribute_wholesale_price'),
Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact'),
Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact'),
Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact'),
Tools::getValue('attribute_ecotax'),
Tools::getValue('id_image_attr'),
Tools::getValue('attribute_reference'),
null,
Tools::getValue('attribute_ean13'),
Tools::getValue('attribute_default'),
Tools::getValue('attribute_location'),
Tools::getValue('attribute_upc')
);
$this->updateDownloadProduct($product, 0, $id_product_attribute);
}
else
$this->_errors[] = Tools::displayError('You do not have permission to').'<hr>'.Tools::displayError('Edit here.');
}
if (!count($this->_errors))
{
$product->addAttributeCombinaison($id_product_attribute, Tools::getValue('attribute_combinaison_list'));
$product->checkDefaultAttributes();
}
if (!count($this->_errors))
{
if (!$product->cache_default_attribute)
Product::updateDefaultAttribute($product->id);
if (!empty($is_virtual))
Product::updateIsVirtual($product->id);
$this->redirect_after = self::$currentIndex.'&id_product='.$product->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=3&token='.($token ? $token : $this->token);
}
}
}
else
$this->_errors[] = Tools::displayError('Could not load Product');
}
public function processFeatures($token)
@@ -801,17 +843,8 @@ class AdminProductsControllerCore extends AdminController
public function initProcess()
{
parent::initProcess();
if ($this->action)
{
if ($this->action == 'new')
$this->action = 'Informations';
return;
}
// Delete a product in the download folder
elseif (Tools::getValue('deleteVirtualProduct'))
if (Tools::getValue('deleteVirtualProduct'))
{
if ($this->tabAccess['delete'] === '1')
$this->action = 'deleteVirtualProduct';
@@ -916,6 +949,16 @@ class AdminProductsControllerCore extends AdminController
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (!$this->action)
parent::initProcess();
if ($this->action)
{
if ($this->action == 'new')
$this->action = 'Informations';
return;
}
}
/**
@@ -1043,20 +1086,11 @@ class AdminProductsControllerCore extends AdminController
$id_product_attribute = (int)Tools::getValue('id_product_attribute');
if ($id_product && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product)))
{
$combinaisons = $product->getAttributeCombinaisonsById($id_product_attribute, $this->context->language->id);
foreach ($combinaisons as $key => $combinaison)
$combinaisons[$key]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']);
$combinations = $product->getAttributeCombinaisonsById($id_product_attribute, $this->context->language->id);
foreach ($combinations as $key => $combinaison)
foreach ($combinaisons as $key => $combinaison)
{
$js_list = '';
asort($combinaison['attributes']);
foreach ($combinaison['attributes'] AS $attribute)
$js_list .= '\''.addslashes(htmlspecialchars($combinaison['group_name'])).' : '.addslashes(htmlspecialchars($combinaison['attribute_name'])).'\', \''.$combinaison['id_attribute'].'\', ';
$combinaisons[$key]['list_attributes'] = rtrim($js_list, ', ');
}
die(Tools::jsonEncode($combinaisons));
$combinations[$key]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']);
die(Tools::jsonEncode($combinations));
}
}
}
@@ -1928,8 +1962,8 @@ class AdminProductsControllerCore extends AdminController
// adding button for adding a new combination in Combinaition tab
$this->toolbar_btn['newCombination'] = array(
'short' => 'Add a new combination',
'desc' => $this->l('Add a new combination'),
'short' => 'New combination',
'desc' => $this->l('New combination'),
'class' => 'toolbar-new'
);
}
@@ -2084,7 +2118,7 @@ class AdminProductsControllerCore extends AdminController
*/
public function processSuppliers($token)
{
if (Tools::getValue('supplier_loaded') && Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product'))))
if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product'))))
{
// Get all id_product_attribute
$attributes = $product->getAttributesResume($this->context->language->id);
@@ -2262,7 +2296,7 @@ class AdminProductsControllerCore extends AdminController
*/
public function processWarehouses($token)
{
if (Tools::getValue('warehouse_loaded') && Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product'))))
if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product'))))
{
// Get all id_product_attribute
$attributes = $product->getAttributesResume($this->context->language->id);
+1 -1
View File
@@ -1020,7 +1020,7 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
(2, 98, 'Etat instantané du stock'),
(2, 99, 'Couverture du stock'),
(2, 100, 'Commandes fournisseurs'),
(2, 101, 'Générateur de combinaisons'),
(2, 101, 'Générateur de déclinaisons'),
(2, 102, 'Comptabilité'),
(2, 103, 'Gestion des numéros de comptes'),
(2, 104, 'Export'),
+1 -1
View File
@@ -551,7 +551,7 @@ ALTER TABLE `PREFIX_hook` ADD `is_native` TINYINT( 1 ) NOT NULL DEFAULT '0';
ALTER TABLE `PREFIX_tax` ADD COLUMN `account_number` VARCHAR(64) NOT NULL;
/* PHP:add_new_tab(AdminAttributeGenerator, fr:Générateur de combinaisons|es:Combinations generator|en:Combinations generator|de:Combinations generator|it:Combinations generator, -1); */;
/* PHP:add_new_tab(AdminAttributeGenerator, fr:Générateur de déclinaisons|es:Combinations generator|en:Combinations generator|de:Combinations generator|it:Combinations generator, -1); */;
/* PHP:add_new_tab(AdminCMSCategories, fr:Catégories CMS|es:CMS categories|en:CMS categories|de:CMS categories|it:CMS categories, -1); */;
/* PHP:add_new_tab(AdminCMS, fr:Pages CMS|es:CMS pages|en:CMS pages|de:CMS pages|it:CMS pages, -1); */;
+4 -9
View File
@@ -142,7 +142,6 @@ function editProductAttribute(ids, token)
$('#product_att_list').html('');
removeButtonCombination('update');
$.scrollTo('#add_new_combination', 1200, { offset: -100 });
var wholesale_price = Math.abs(data[0]['wholesale_price']);
var price = Math.abs(data[0]['price']);
var weight = Math.abs(data[0]['weight']);
@@ -151,17 +150,13 @@ function editProductAttribute(ids, token)
var ean = data[0]['ean13'];
var quantity = data[0]['quantity'];
var image = false;
var old_attr = Array(data[0]['list_attributes']);
var product_att_list = '';
var product_att_list = new Array();
for(i=0;i<data.length;i++)
{
product_att_list += data[i]['group_name']+' : ';
product_att_list += data[i]['attribute_name']+', ';
product_att_list += data[i]['id_attribute']+', ';
product_att_list.push(data[i]['group_name']+' : '+data[i]['attribute_name']);
product_att_list.push(data[i]['id_attribute']);
}
var old_attr = Array(product_att_list.substr(0, (product_att_list.length-2)));
var id_product_attribute = data[0]['id_product_attribute'];
var default_attribute = data[0]['default_on'];
var eco_tax = data[0]['ecotax'];
@@ -184,7 +179,7 @@ function editProductAttribute(ids, token)
ean,
quantity,
image,
old_attr,
product_att_list,
id_product_attribute,
default_attribute,
eco_tax,
-1
View File
@@ -144,7 +144,6 @@ virtual_product_nb_days, is_shareable)
var opt = document.createElement('option');
opt.text = old_attr[i++];
opt.value = old_attr[i];
try {
elem.add(opt, null);
}
+10 -8
View File
@@ -1692,7 +1692,7 @@ $_LANGADM['AdminPPreferences044a77653804fe33652d68098d98121e'] = 'Utiliser l\'an
$_LANGADM['AdminPPreferencese7ed00268dc16aecaac5a60aeb6f4c73'] = 'Ce réglage doit rester sur \"Oui\" à moins que vous nayez déplacé avec succès les images dans l\'onglet Préférences > Image';
$_LANGADM['AdminPPreferences88694e637431115721b5241e652a178f'] = 'Remises des quantités basées sur:';
$_LANGADM['AdminPPreferences68217d833599eb6fb56f9e6d2ca24196'] = 'Comment calculer les remises de quantité';
$_LANGADM['AdminPPreferencesb9208b03bcc9eb4a336258dcdcb66207'] = 'Combinaisons';
$_LANGADM['AdminPPreferencesb9208b03bcc9eb4a336258dcdcb66207'] = 'Déclinaisons';
$_LANGADM['AdminWarehouses63d5049791d9d79d86e9a108b0a999ca'] = 'Référence';
$_LANGADM['AdminWarehouses49ee3087348e8d44e1feda1917443987'] = 'Nom';
$_LANGADM['AdminWarehouses20890e791d8923cfff55ce5331259b34'] = 'Méthode de valorisation';
@@ -2943,7 +2943,7 @@ $_LANGADM['AdminImport84005574d8d764336cd8e9207de82506'] = 'Seuls les fichiers U
$_LANGADM['AdminImport9db4c047fbc2df77e904876ca407a10a'] = 'Exemple de fichiers';
$_LANGADM['AdminImportc0cad1da1e9b23dd6e383276f8e3950e'] = 'Exemple de fichier catégories';
$_LANGADM['AdminImportc0bc21edce0f247286513a9f524a3c3e'] = 'Exemple de fichier produits';
$_LANGADM['AdminImport0a8b4817e5c1e8849b9cbd65997441b5'] = 'Exemple de fichier combinaisons';
$_LANGADM['AdminImport0a8b4817e5c1e8849b9cbd65997441b5'] = 'Exemple de fichier déclinaisons';
$_LANGADM['AdminImport1b10c2304e2f49d53c39bc40fd393335'] = 'Exemple de fichier clients';
$_LANGADM['AdminImport2f5e75d22f59829ba10e2e6276321af8'] = 'Exemple de fichier adresses';
$_LANGADM['AdminImport54b4744bfd46cc4e06988ee168b13abf'] = 'Exemple de fichier fabricants';
@@ -3101,7 +3101,7 @@ $_LANGADM['AdminProductsd88946b678e4c2f251d4e292e8142291'] = 'Référencement';
$_LANGADM['AdminProductsfff0d600f8a0b5e19e88bfb821dd1157'] = 'Images';
$_LANGADM['AdminProducts0063394f0497bfd610ebac0aee7cfc34'] = 'Associations';
$_LANGADM['AdminProductsea9cf7e47ff33b2be14e6dd07cbcefc6'] = 'Transports';
$_LANGADM['AdminProductsb9208b03bcc9eb4a336258dcdcb66207'] = 'Combinaisons';
$_LANGADM['AdminProductsb9208b03bcc9eb4a336258dcdcb66207'] = 'Déclinaisons';
$_LANGADM['AdminProducts98f770b0af18ca763421bac22b4b6805'] = 'Caractéristiques';
$_LANGADM['AdminProductsda22c93ccb398c72070f4000cc7b59a1'] = 'Personnalisation';
$_LANGADM['AdminProducts7e2708aeb65763c54052f57ed1a1ec1d'] = 'Pièces jointes';
@@ -3173,6 +3173,7 @@ $_LANGADM['AdminProductsc3987e4cac14a8456515f0d200da04ee'] = 'Tous les pays';
$_LANGADM['AdminProductse4c4c68c7515704a91d90207067dcbbe'] = 'Tous les groupes';
$_LANGADM['AdminProductsf2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer';
$_LANGADM['AdminProducts4d774376eedc9e76eb3ecd52629ca6d5'] = 'Gestion des priorités';
$_LANGADM['AdminProductsc572a4eb27e155bf026a8e030a153be0'] = 'Parfois un client peut être concerné par plusieurs règles de prix spécifiques simultanément. Les priorités vous permettent de décider quelle règle sera appliquée.';
$_LANGADM['AdminProducts77b4fe51b2eede1e804277e64ceb9a22'] = 'Priorités :';
$_LANGADM['AdminProducts9f82518d468b9fee614fcc92f76bb163'] = 'Boutique';
$_LANGADM['AdminProducts386c339d37e737a436499d423a77df0c'] = 'Devise';
@@ -3283,8 +3284,8 @@ $_LANGADM['AdminProducts4b5ecb6f4e1496fb2c2b28fa0f41872a'] = 'La date de disponi
$_LANGADM['AdminProducts461900b74731e07320ca79366df3e809'] = 'Image :';
$_LANGADM['AdminProductse5f7f63d66023847e693fd34bea09d41'] = 'Par défaut :';
$_LANGADM['AdminProducts29d7b46b863639e29ae8452d2320530a'] = 'Faire de cette déclinaison celle par défaut pour ce produit';
$_LANGADM['AdminProductsadbabbab7becdf5ef8736a64466df260'] = 'Ajouter cette déclinaison';
$_LANGADM['AdminProducts040c4cd298c6f710e3862d94a4d1145c'] = 'Modifier cette combinaison';
$_LANGADM['AdminProductsadbabbab7becdf5ef8736a64466df260'] = 'Nouvelle déclinaison';
$_LANGADM['AdminProducts040c4cd298c6f710e3862d94a4d1145c'] = 'Modifier cette déclinaison';
$_LANGADM['AdminProductsefb41efb550c9beaa9291985f7fa850a'] = 'Ajouter ce groupe de déclinaisons';
$_LANGADM['AdminProducts9230dd17b40c6d0478772e4d545abc46'] = 'Annuler la modification';
$_LANGADM['AdminProducts5fd58de80d182944e9c229aa4c3b8180'] = 'Ajouter ou modifier des propriétés personnalisables';
@@ -3390,10 +3391,11 @@ $_LANGADM['AdminProducts7b988b81a5fe3114360063de23f49016'] = 'Prix de vente fina
$_LANGADM['AdminProductse2e79605fc9450ec17957cf0e910f5c6'] = 'TTC';
$_LANGADM['AdminProducts887ee91702c962a70b87cbef07bbcaec'] = 'HT';
$_LANGADM['AdminProducts5b14ab8904d8a735edd6ea4cff8f7b7c'] = 'Prix spécifiques';
$_LANGADM['AdminProducts146aed434d7f1d22ee1dd69663122b16'] = 'Vous pouvez définir des prix spécifiques pour des clients appartenant à différents groupes, différents pays...';
$_LANGADM['AdminProductsc1649abdccba825a27f5820f126c8454'] = 'Ajouter un nouveau prix spécifique';
$_LANGADM['AdminProductsf98188b975d57e9dfc3137c7c9f9a5da'] = 'Pour :';
$_LANGADM['AdminProducts8ed07686e8486f87c4e0d491b0949904'] = 'Combinaison :';
$_LANGADM['AdminProductsc77b86cdeed7ed9197db5858fa3b5fd0'] = 'Appliquer à toutes les combinaisons';
$_LANGADM['AdminProducts8ed07686e8486f87c4e0d491b0949904'] = 'Déclinaison :';
$_LANGADM['AdminProductsc77b86cdeed7ed9197db5858fa3b5fd0'] = 'Appliquer à toutes les déclinaisons';
$_LANGADM['AdminProducts06444363878572ed1fd5c9342cd5884f'] = 'Disponible à partir de :';
$_LANGADM['AdminProducts01b6e20344b68835c5ed1ddedf20d531'] = 'à';
$_LANGADM['AdminProducts95b6faa9d75417fe5e7767a733ab6fb4'] = 'À partir de';
@@ -3406,7 +3408,7 @@ $_LANGADM['AdminProductsb2f40690858b404ed10e62bdf422c704'] = 'Montant';
$_LANGADM['AdminProducts37be07209f53a5d636d5c904ca9ae64c'] = 'Pourcentage';
$_LANGADM['AdminProducts61946eb3e50f01d7ea339f202a2942f8'] = '(s\'il est réglé sur \"Montant\", la taxe est incluse)';
$_LANGADM['AdminProductsab7a485ebe75b6dd7243ad719f23c7de'] = 'Règle';
$_LANGADM['AdminProducts47ac923d219501859fb68fed8c8db77b'] = 'Combinaison';
$_LANGADM['AdminProducts47ac923d219501859fb68fed8c8db77b'] = 'Déclinaison';
$_LANGADM['AdminProducts3601146c4e948c32b6424d2c0a7f0118'] = 'Prix';
$_LANGADM['AdminProducts7f5f43f70aaffba55924eaa4b51d9eb3'] = '(HT)';
$_LANGADM['AdminProducts1901606ea069a83dc7beea17881ef95a'] = 'Période';
+2 -2
View File
@@ -256,7 +256,7 @@ $_ERRORS['298883b17e36ee3a18d73e835c0b44fc'] = 'Aucun fichier n\'a été envoyé
$_ERRORS['20c6125376d8de28149d655c7cc25e32'] = 'Aucun fichiers n\'a été envoyés';
$_ERRORS['cb20447a4bf5ff9bec717ec68a357a93'] = 'Aucun moteur de rendu choisi';
$_ERRORS['ccacacd12f75e1ab3f9ce3e234ed5777'] = 'Aucun moteur de tableau sélectionné';
$_ERRORS['774eec2772b5f57b2e13d11e1b093a4f'] = 'Aucune image trouvée pour la combinaison avec id_product = %s et la position de l\'image = %s.';
$_ERRORS['774eec2772b5f57b2e13d11e1b093a4f'] = 'Aucune image trouvée pour la déclinaison avec id_product = %s et la position de l\'image = %s.';
$_ERRORS['0e63e5844a0255aeb0cee434263552ae'] = 'aucune facture avec cet ID:';
$_ERRORS['e21c3c406358073b38d481fd3d88221c'] = 'Aucune facture trouvée';
$_ERRORS['f59b67acbc1ca8ecad71a742f5e43b09'] = 'aucune commande avec cet ID:';
@@ -347,7 +347,7 @@ $_ERRORS['71f4f008985ea6abc73e89a668e15197'] = 'Cet attribut existe déjà.';
$_ERRORS['ecc5c9c627d8b41fc33888b5b17ea1a5'] = 'Cette classe dépend de plusieurs fichiers modifiés dans la version 1.4.5.0 et ne doit pas être utilisé dans une version plus ancienne';
$_ERRORS['ecc5c9c627d8b41fc33888b5b17ea1a5'] = 'Cette classe dépend de plusieurs fichiers modifiés en v1.4.5 et ne devrait pas être utilisée dans une ancienne version';
$_ERRORS['e49f206b6d8f0e5e2a6cb13d96b44ed2'] = 'Ce nom de classe n\'existe pas';
$_ERRORS['e22a6ea51eb74bee7acaa4acf2846c7b'] = 'Cette combinaison existe déjà';
$_ERRORS['e22a6ea51eb74bee7acaa4acf2846c7b'] = 'Cette déclinaison existe déjà';
$_ERRORS['d51499b48399054d809f49bce078923e'] = 'Ce client existent déjà en tant que non-invité.';
$_ERRORS['8562db06e3931e51ac8c456b56088b02'] = 'Le client n\'existe pas';
$_ERRORS['350e5d76b60ae887c90d55e2fb23fdc5'] = 'ce bon de réduction n\'est pas applicable à cette catégorie de produit';