exootia Posted May 3, 2014 Share Posted May 3, 2014 Bonjour à tous, Je suis à la recherche d'un module (dans l'idéal gratuit) qui permet d'ajouter des ingrédients à tous mes produits (un simple champ text textarea suffirait). Savez-vous si je peux trouver ça ? Merci d'avance Link to comment Share on other sites More sharing options...
loulou66 Posted May 3, 2014 Share Posted May 3, 2014 Coucou sur PS 1.6 dans la BO=>catalogues=>produits onglet personnalisation tu met 1 a "Champs de texte" tu enregistres et tu rempli selon ton choix le champ apparaîtras en FO ou le client pourra remplir un champ text sinon il y a le module deVekia http://www.prestashop.com/forums/topic/189039-module-html-box-for-free/ ou tu peut ajouter ce que tu veut sur les Hook existant dans les pages PS @++ Loulou66 Link to comment Share on other sites More sharing options...
exootia Posted May 6, 2014 Author Share Posted May 6, 2014 Salut, merci pour la réponse. Le module ne semble pas convenir car le client devra avoir des ingrédients différent selon les produits. Pour l'onglet personnsalition, ca ne correspond pas vraiment à ce que je veux.Sinon, est-ce que quelqu'un sait si cette technique fonctionne sur les versions récentes de prestashop ? Link to comment Share on other sites More sharing options...
loulou66 Posted May 6, 2014 Share Posted May 6, 2014 Coucou oui ça devrait fonctionner prend avec l'exemple Versions 1.5.4+ @++ loulou66 Link to comment Share on other sites More sharing options...
exootia Posted May 7, 2014 Author Share Posted May 7, 2014 Super ca marche a la perfection !Je vais tenter, pour terminer (^^), d'adapter ce code pour une checkbox : je voudrais pouvoir indiquer quand il s'agit d'un produit bio ou non... ya plus qu'a ! Link to comment Share on other sites More sharing options...
exootia Posted May 17, 2014 Author Share Posted May 17, 2014 (edited) Ca fonctionne également avec un checkbox, avec quelques modifications bien entendu.J'ai voulu faire ça pour pouvoir indiquer sur il s'agit d'un produit bio ou non, voici comment j'ai fais :J'ai donc pratiquement tout fait comme dans ce tuto.Pour le champ a crée dans la bdd je l'ai crée en int au lieu de text (logique, vu que je les données seront à 0 si la case n'est pas cochée et à 1 si elle est cochée). Dans override/classes/Product.php j'ai ça (pour un textarea et un checkbox) class Product extends ProductCore { public $composition; public $bio; public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) { Product::$definition['fields']['composition'] = array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'); Product::$definition['fields']['bio'] = array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'); parent::__construct($id_product, $full, $id_lang, $id_shop, $context); } } Dans le fichier informations.tpl, au lieu du textarea j'ai ça : <input type="hidden" name="$product->bio_{$language.id_lang}" id="$product->bio_{$language.id_lang}" value="0" /> <input type="checkbox" name="$product->bio_{$language.id_lang}" id="$product->bio_{$language.id_lang}" value="1" {if $product->bio[$language.id_lang]}checked="checked"{/if} /> Edited May 17, 2014 by exootia (see edit history) Link to comment Share on other sites More sharing options...
exootia Posted May 21, 2014 Author Share Posted May 21, 2014 Je reviens car je voudrais encore apporter une légère amméilloration. Je souhaiterai pouvoir également faire apparaitre ça dans le template product-list.tpl mais je ne vois pas comment. Quelqu'un aurait une idée ? Link to comment Share on other sites More sharing options...
loulou66 Posted May 22, 2014 Share Posted May 22, 2014 Coucou dans le tuto c'est expliquer en IV pour recupérer le pl.NomDuCchampQueTuAsCréerDdansTaBdd @++ Loulou66 Link to comment Share on other sites More sharing options...
exootia Posted May 22, 2014 Author Share Posted May 22, 2014 Ah oui je suis stupide... je vais voir ça.Merci Link to comment Share on other sites More sharing options...
exootia Posted May 22, 2014 Author Share Posted May 22, 2014 (edited) Re, j'ai essayé, mais sans succès :/ Dans override/classes/Category.php voici ce que j'ai : <?php public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null) { if (!$context) $context = Context::getContext(); if ($check_access && !$this->checkAccess($context->customer->id)) return false; $front = true; if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) $front = false; if ($p < 1) $p = 1; if (empty($order_by)) $order_by = 'position'; else /* Fix for all modules which are now using lowercase values for 'orderBy' parameter */ $order_by = strtolower($order_by); if (empty($order_way)) $order_way = 'ASC'; if ($order_by == 'id_product' || $order_by == 'date_add' || $order_by == 'date_upd') $order_by_prefix = 'p'; elseif ($order_by == 'name') $order_by_prefix = 'pl'; elseif ($order_by == 'manufacturer') { $order_by_prefix = 'm'; $order_by = 'name'; } elseif ($order_by == 'position') $order_by_prefix = 'cp'; if ($order_by == 'price') $order_by = 'orderprice'; if (!Validate::isBool($active) || !Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) die (Tools::displayError()); $id_supplier = (int)Tools::getValue('id_supplier'); /* Return only the number of products */ if ($get_total) { $sql = 'SELECT COUNT(cp.`id_product`) AS total FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product` WHERE cp.`id_category` = '.(int)$this->id. ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : ''). ($active ? ' AND product_shop.`active` = 1' : ''). ($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : ''); return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); } $sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl`bio`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new, product_shop.price AS orderprice FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`) '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').' '.Product::sqlStock('p', 'product_attribute_shop', false, $context->shop).' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').') LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').') LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'. Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE product_shop.`id_shop` = '.(int)$context->shop->id.' AND cp.`id_category` = '.(int)$this->id .($active ? ' AND product_shop.`active` = 1' : '') .($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') .($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '') .' GROUP BY product_shop.id_product'; if ($random === true) { $sql .= ' ORDER BY RAND()'; $sql .= ' LIMIT 0, '.(int)$random_number_products; } else $sql .= ' ORDER BY '.(isset($order_by_prefix) ? $order_by_prefix.'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); if ($order_by == 'orderprice') Tools::orderbyPrice($result, $order_way); if (!$result) return array(); /* Modify SQL result */ return Product::getProductsProperties($id_lang, $result); } ?> J'ai donc rajouté mon champ (pl.bio) ici mais je ne suis sur d'avoir bien fait à ce niveau :/ (je l'ai mis en gras ci-dessous$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl`bio Edited May 22, 2014 by exootia (see edit history) Link to comment Share on other sites More sharing options...
loulou66 Posted May 22, 2014 Share Posted May 22, 2014 Coucou c'est pl.`bio` pl point tilde BIO tilde ou pl correspond a la table product_lang @++ Loulou66 Link to comment Share on other sites More sharing options...
exootia Posted June 14, 2014 Author Share Posted June 14, 2014 Hello, Je reviens (un peu tard), j'ai donc corrigé cette stupide erreur, mais ça ne fonctionne toujours pas :/ $sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`bio`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(), Est-ce que tu aurais une idée ? Link to comment Share on other sites More sharing options...
loulou66 Posted June 14, 2014 Share Posted June 14, 2014 (edited) Coucou Comme ça je ne voit pas regarde un de mes post qui traite du sujet il a y la soluce pour Ps 1.6 et plus bas pour PS 1.5 la même chose pour une case ça cocher en BO qui change l'image "new" en FO si tu l'adapte pour toi tu aura la conditions en FO. http://www.prestashop.com/forums/topic/192268-ajouter-un-bandeau-nouveau-sur-les-nouveaux-produits/ {if $product.bio} bla bla {/if} Pour vérifier que tu a bien la variable $product->bio dans paramètres avancées==>performance active les console de debug smarty a chaque appel, ensuite va dans la page d'un produits une petite fenêtre va s'ouvrir (autoriser les pop_up avec chrome le 1er fois pour le site); dans cette fenêtré tu fait CTRL+F pour activer la recherche dans cette fenêtre tu tapes $prod et cela t'emmène au variable pour les produits($product)( colonne de gauche)et tu recherches ta variable bio dans la colonne de droite, elle est soit a 0 (si tu n'as pas cocher en BO la case) soit a 1 (si tu a cocher en BO la case a cocher que tu as créer). Tu n'as même pas besoin de modifier la requête sql car elle prend toute les colonne avec p.* mais il faut créer les colonne dans les table product et product_shop. Par contre je n'ai pas fait un override de la classe product tu perdras les changement lors d'une mise a jour de PS ( de 1.5 a 1.6 par exemple). Si tu n'y arrive toujours pas il faudra qu'on se retrouve sur skype ou teamviewer pour que je check tes fichiers modifier @++ Loulou66 Edited June 14, 2014 by loulou66 (see edit history) Link to comment Share on other sites More sharing options...
exootia Posted June 27, 2014 Author Share Posted June 27, 2014 Salut Loulou66 Effectivement, avec le debug je me rend compte que je n'ai pas le champ bio dans ma liste de produits Je vais essayer de trouver, tu peux me donner ton compte skype au cas ou stp ? Merci à toi Link to comment Share on other sites More sharing options...
exootia Posted October 11, 2014 Author Share Posted October 11, 2014 Salut, Je remonte le topic car je n'ai toujours pas vraiment réussi à corriger ce problème. Si je rajoute pl.`bio` dans le SELECT du fichier /classes/Category.php ça fonctionne, mais pas quand j'utilise le fichier /override/classes/Category.php Une idée de pourquoi ? Je met mon fichier ici, si quelqu'un aurait le temps de jeter un oeil ce serait vraiment sympa http://exootia.fr/Category.zip Merci d'avance Link to comment Share on other sites More sharing options...
Recommended Posts