exootia Posted June 14, 2014 Share Posted June 14, 2014 Salut à tous, comme précisé dans le titre, je cherche à intégrer la liste des attributs sur le template product-list.tpl. En fait, j'ai un attribut conditionnement, et je souhaite affiché le conditionnement par défaut. Malgré mes recherches je n'ai rien trouvé, quelqu'un aurait la solution ? Merci d'avance Link to comment Share on other sites More sharing options...
exootia Posted June 16, 2014 Author Share Posted June 16, 2014 Up ? Link to comment Share on other sites More sharing options...
starchoon Posted July 24, 2014 Share Posted July 24, 2014 As tu trouvé une solution ? Link to comment Share on other sites More sharing options...
exootia Posted October 11, 2014 Author Share Posted October 11, 2014 As tu trouvé une solution ? Non :/ Si quelqu'un a la solution... Link to comment Share on other sites More sharing options...
cirylBD28 Posted November 27, 2014 Share Posted November 27, 2014 Pareil pour moi, je recherche à faire plus ou moins la même chose. En fait, pour ma part, je veux afficher uniquement le nom de la déclinaison affichée par défaut. Si quelqu'un a une idée ? Link to comment Share on other sites More sharing options...
Alexandre Carette Posted November 27, 2014 Share Posted November 27, 2014 il y a un tuto ici: http://www.prestashop.com/forums/topic/279551-how-to-show-product-attribute-option-in-product-list/ Link to comment Share on other sites More sharing options...
cirylBD28 Posted November 29, 2014 Share Posted November 29, 2014 Merci alexandre-km, c'est déjà une bonne piste. Je vais y regarder de plus près ce week-end. Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 1, 2014 Share Posted December 1, 2014 (edited) il y a un tuto ici: http://www.prestashop.com/forums/topic/279551-how-to-show-product-attribute-option-in-product-list/ J'ai regardé ce tuto et plusieurs autres et je dois dire que je galère pas mal. Pour ajouter un menu déroulant avec la liste déclinaisons dispos, ça le fait. Mais c'est pas ce que je veux... Je veux juste récupérer le "name" de la déclinaison par défaut et l'afficher en-dessous de mon prix lors du "hover". Si quelqu'un a une idée? Edited December 1, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 2, 2014 Share Posted December 2, 2014 est ce que dans la console debug tu as les variables souhaitées ? Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 2, 2014 Share Posted December 2, 2014 (edited) oui et non, j'ai toutes les déclinaisons de chacun de mes produits mais comment identifier celle par défaut ? Ou comment relier le name avec l'id correspondant ? Edited December 2, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 2, 2014 Share Posted December 2, 2014 Pourrais tu faire une capture d'écran de la console la ou il y a les variables de declinaison ? Parce que tu pourrais faire un foreach sur le tableau et assigner une variable... Ex ci dessous j ai assigné l'id de l'image par défaut d'un produit dans la variable pinimg {foreach from=$images item=image key=id} {if $image.cover == 1} {assign var=pinimg value=$image.id_image} {/if} {/foreach} Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 2, 2014 Share Posted December 2, 2014 (edited) En l'occurence, le nom de la déclinaison par défaut qu'il me faut récupérer est "lot de 6 pièces de 150g (20,24€/Kg)" Edited December 2, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 2, 2014 Share Posted December 2, 2014 (edited) la declinaison par defaut est "lot de 6 pieces 150 grs" ? faut donc faire une condition après le foreach du genre, je ne suis pas sur de ce code, il faut tester {foreach from=$product item=attributes key=name} {if $attributes->default_on == 1} {assign var=declinaisonpardefaut value=$attributes.name} {/if} {/foreach} tu appelles la variable dans le tpl avec {$declinaisonpardefaut} Edited December 2, 2014 by Alexandre-KM (see edit history) Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 2, 2014 Share Posted December 2, 2014 (edited) Bon... j'approche je pense. voici mon code surchargé pour categorie.php public function getProductAttributeCombinations($products) { $combinations = array(); foreach($products as $product) { // load product object $product = new Product ($product['id_product'], $this->context->language->id); // get the product combinations data // create array combinations with key = id_product $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } + dans le initcontent de ce meme categorie.php public function initContent() { parent::initContent(); $products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); $combinations = $this->getProductAttributeCombinations($products); ....... ...... + ajout de l'assign pour $combinations et enfin dans mon product-list.tpl : {foreach from=$combinations key=k item=comb} {if $product.id_product == $k} <p class="comb_title">{$comb.group_name}</p> <select> {foreach from=$comb item=attr} <option value="{$attr.id_attribute}">{$attr.attribute_name}</option> {/foreach} </select> {/if} {/foreach} Et pour finir, voilà le résultat : J'ai donc maintenant une liste déroulante correspondante par produit. Mais toujours pas la bonne valeur qui s'affiche (puisque ma liste déroulante prend la première valeur) Edited December 2, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 4, 2014 Share Posted December 4, 2014 tu n'as pas oublié la condition {if $attributes->default_on == 1} {/if} ? Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 4, 2014 Share Posted December 4, 2014 (edited) tu n'as pas oublié la condition {if $attributes->default_on == 1} {/if} ? J'ai essayé en plaçant le if mais rien ne s'affiche {if ($product.id_product_attribute!='0')}<span class="a_partir_de"> {if !$priceDisplay}{convertPrice price=$product.price} {foreach from=$combinations key=k item=comb} {if $product.id_product == $k} {foreach from=$comb item=attr} {if $comb->default_on == 1} <p value="{$attr.id_attribute}">{$attr.attribute_name}</p> {/if} {/foreach} {/if} {/foreach} </span>{/if} Edited December 4, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 4, 2014 Share Posted December 4, 2014 (edited) C'est bon j'ai trouvé !!! \o/ Je plaçais pas mon if au bon endroit Pour ceux que ça aiderait : {foreach from=$combinations key=k item=comb} {if $product.id_product == $k} {foreach from=$comb item=attr} {if $attr.default_on =='1'} <p>{$attr.attribute_name}</p> {/if} {/foreach} {/if} {/foreach} Edited December 4, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 4, 2014 Share Posted December 4, 2014 Une dernière petite chose... L'affichage est OK qd je suis dans une catégorie mais ne fonctionne pas sur le module des produits phares en page d'accueil. Je pense qu'il ne va pas chercher les infos dans categoryController. Une idée du controller ou ajouter la fonction pour le homefeatured ? Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 4, 2014 Share Posted December 4, 2014 il faut faire la meme chose dans le module, regarde dans homefeatured.php et rajoute les fonctions Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 10, 2014 Share Posted December 10, 2014 (edited) il faut faire la meme chose dans le module, regarde dans homefeatured.php et rajoute les fonctions Bonsoir, Je remonte un peu le topic car j'ai pas mal évolué sur d'autres choses entre temps tout en cherchant en résoudre ce souci. J'ai tenté plusieurs choses, dont le rajout de la fonction dans homefeatured.php mais sans résultat probant... (Rien ne s'affiche) Je joins le code, des fois que Alexandre-KM passe par là ;-) class HomeFeatured extends Module { protected static $cache_products; public function getProductAttributeCombinations($cache_products) { $combinations = array(); foreach($cache_products as $product) { $product = new Product ($product['id_product'], $this->context->language->id); $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } public function hookDisplayHome($params) { if (!$this->isCached('homefeatured.tpl', $this->getCacheId())) { $this->_cacheProducts(); $combinations = $this->getProductAttributeCombinations($cache_products); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'combinations' => $combinations, ) ); } return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId()); } Edited December 10, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 11, 2014 Share Posted December 11, 2014 J'ai tenté plusieurs choses, dont le rajout de la fonction dans homefeatured.php mais sans résultat probant... (Rien ne s'affiche) Quand tu ajoutes la fonction ca te donne une page blanche ? si c'est le cas tu dois avoir des erreurs, il faut pouvoir les identifier en activant le mode debug, dans le dossier /config/ fichier defines.inc.php : remplacer: define('_PS_MODE_DEV_', false); en: define('_PS_MODE_DEV_', true); Cela fera en sorte de te montrer sur ton navigateur les erreurs PHP, et de voir si c'est ta fonction qui déconne. Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 11, 2014 Share Posted December 11, 2014 Non, j'ai pas une page blanche, mais ma variable n'est semble t-il pas récupérée puisque elle ne s'affiche pas. Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 11, 2014 Share Posted December 11, 2014 la variable $combinations n existe pas dans la console DEBUG ? Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 14, 2014 Share Posted December 14, 2014 (edited) la variable $combinations n existe pas dans la console DEBUG ? Elle existe mais j'au un array vide : $combinations Smarty_Variable Object (3) ->value = Array (0) ->nocache = false ->scope = "file:/var/www/vhosts/ns3319526.ovh.ne..." Mais tout compte fait, quand on cherche on trouve, ma variable $products dans mon HookDisplayHome était mal récupérée voilà la bonne solution : $products = HomeFeatured::$cache_products; Edited December 14, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 14, 2014 Share Posted December 14, 2014 /* 256: * Get product combinations 257: */ 258: public static function getProductAttributeCombination($id_product_attribute, $id_lang) 259: { 260: $sql = ' 261: SELECT al.`name` AS attribute_name 262: FROM `'._DB_PREFIX_.'product_attribute_combination` pac 263: LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`) 264: LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`) 265: LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.') 266: LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.') 267: LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`) 268: '.Shop::addSqlAssociation('product_attribute', 'pa').' 269: WHERE pac.`id_product_attribute` = '.(int)$id_product_attribute; 270: 271: return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); 272: } http://doc4dev.net/doc/PrestaShop/1/source-class-MailAlert.html#258-272 ca peut peu être t-aider 1 Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 14, 2014 Share Posted December 14, 2014 Il ne me manque plus qu'à trouver la bonne solution pour SearchController.... Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 14, 2014 Share Posted December 14, 2014 Merci de ton aide précieuse Alexandre-KM, un vrai plaisir de trouver des gens aussi ouverts. J'ai également modifiéSearchController et tout fonctionne à merveille !!! Pour ma part, tout est OK ! 1 Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 14, 2014 Share Posted December 14, 2014 (edited) Dernière petite chose que je remarque à l'instant : Quand le cache est activé, mes combinaisons ne sont pas récupérées et n'apparaissent plus, uniquement dans homefeatures... Pour searchController et CategoryController, pas de soucis... une idée ? Edited December 14, 2014 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted December 14, 2014 Share Posted December 14, 2014 Peut être virer la condition if cache, if (!$this->isCached('homefeatured.tpl', $this->getCacheId())) if (!$this->isCached('homefeatured.tpl', $this->getCacheId())) { $this->_cacheProducts(); $combinations = $this->getProductAttributeCombinations($cache_products); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'combinations' => $combinations, ) ); } 1 Link to comment Share on other sites More sharing options...
cirylBD28 Posted December 14, 2014 Share Posted December 14, 2014 En effet, honte à moi... j'aurais pu le deviner... Merci encore ! 1 Link to comment Share on other sites More sharing options...
BusyBusy Posted September 9, 2015 Share Posted September 9, 2015 (edited) Salut à tous, je remets ce topic à jour car je n'ai pas réussi à effectuer la manip pour homefeatured. Ma console de debug ne m'affiche même pas la variable $combinations... Si qqun peut m'aider (voir même attacher le fichier modifié sur le topic ^^) A bientôt, Ronan. PS : version PS 1.5.4 Edited September 9, 2015 by BusyBusy (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 9, 2015 Share Posted September 9, 2015 Salut, Tu as pourtant toutes les infos pour réussir, persevérence.... Si tu nous expliqué précisement ton pb ce forum pourra t'aider ! bon courage Link to comment Share on other sites More sharing options...
BusyBusy Posted September 9, 2015 Share Posted September 9, 2015 Salut Alexandre-KM, merci pour ta réponse. Je comprends le principe de faire par soi même pour comprendre mais là je sèche... J'ai suivi la procédure sur ce topic ainsi que tu le tuto du lien (qui est bien expliqué d'ailleurs) : Dans mon fichier homefeatured.php j'ai : class HomeFeatured extends Module { protected static $cache_products; public function getProductAttributeCombinations($cache_products) { $combinations = array(); foreach($cache_products as $product) { $product = new Product ($product['id_product'], $this->context->language->id); $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } puis ceci : public function hookDisplayHome($params) { if (!$this->isCached('homefeatured.tpl', $this->getCacheId())) { $this->_cacheProducts(); $products = HomeFeatured::$cache_products; $combinations = $this->getProductAttributeCombinations($cache_products); $this->smarty->assign( array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'combinations' => $combinations, ) ); } et dans mon fichier smarty homefeatured.tpl : {foreach from=$combinations key=k item=comb} {if $products.id_product == $k} {* The attribute Group Name *} <p class="comb_title">{$comb.group_name}</p> {* List of attribute values inside the attribute Group for current product *} <select> {foreach from=$comb item=attr} <option value="{$attr.id_attribute}">{$attr.attribute_name} {l s=': +'} {convertPrice price=$attr.unit_price_impact}</option> {/foreach} </select> {/if} {/foreach} Donc j'ai pas de variables $combinations qui se charge dans ma fenêtre de debug et lorsque je fais {$combinations|print_r} j'ai Array 1() et c'est tout.. je suis embêté du coup... si tu peux au moins m'aguiller je t'en serais grandement reconnaisant! Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 9, 2015 Share Posted September 9, 2015 ok tu as bien ca dans ton fichier ? public function hookDisplayHomeTabContent($params) { return $this->hookDisplayHome($params); } et dans index tpl de ton theme: <div class="tab-content">{$HOOK_HOME_TAB_CONTENT}</div> Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 9, 2015 Share Posted September 9, 2015 public function hookDisplayHome($params) { if (!$this->isCached('homefeatured.tpl', $this->getCacheId())) { $this->_cacheProducts(); $combinations = $this->getProductAttributeCombinations($cache_products); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'combinations' => $combinations, ) ); } return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId()); } Link to comment Share on other sites More sharing options...
BusyBusy Posted September 9, 2015 Share Posted September 9, 2015 public function hookDisplayHome($params) { if (!$this->isCached('homefeatured.tpl', $this->getCacheId())) { $this->_cacheProducts(); $combinations = $this->getProductAttributeCombinations($cache_products); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'combinations' => $combinations, ) ); } return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId()); } Je viens d'effectuer le chagement rien de neuf. Concernant public function hookDisplayHomeTabContent($params) { return $this->hookDisplayHome($params); } oui cette fonction est bien dans mon fichier. <div class="tab-content">{$HOOK_HOME_TAB_CONTENT}</div> à quoi me sert ce hook ? j'ai déjà {$HOOK_HOME} qui affiche mes données Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 9, 2015 Share Posted September 9, 2015 (edited) essaye en virant la condition du cache: public function hookDisplayHome($params) { $combinations = $this->getProductAttributeCombinations($cache_products); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, //y aura ptetre un pb ici 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'combinations' => $combinations, ) ); return $this->display(__FILE__, 'homefeatured.tpl'); } Edited September 9, 2015 by Alexandre-KM (see edit history) Link to comment Share on other sites More sharing options...
BusyBusy Posted September 9, 2015 Share Posted September 9, 2015 (edited) Effectivement cela crée un pb : cela ne trouve plus les produits Ptite question, il serait pas plus judicieux d'utiliser la fonction getProducts de la class category ? Edited September 9, 2015 by BusyBusy (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 9, 2015 Share Posted September 9, 2015 oui tu peux essayer , mais c byzaree que combinaison ne soit pas assigné a smarty Link to comment Share on other sites More sharing options...
cirylBD28 Posted September 9, 2015 Share Posted September 9, 2015 Pour ma part ça fonctionne comme ça : dans homefeatured.php public $combinations; public function getProductAttributeCombinations($products) { $combinations = array(); foreach($products as $product) { $product = new Product ($product['id_product'], $this->context->language->id); $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } et ensuite pour la fonction HookDisplayHome : public function hookDisplayHome($params) { if(!$products){ $products = HomeFeatured::$cache_products; $combinations = $this->getProductAttributeCombinations($products); $this->context->smarty->assign('combinations', $combinations); $this->_cacheProducts(); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'combinations' => $combinations, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } else { $products = $products; $combinations = $this->getProductAttributeCombinations($products); $this->context->smarty->assign('combinations', $combinations); $this->_cacheProducts(); $this->smarty->assign( array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'combinations' => $combinations, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId()); Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 9, 2015 Share Posted September 9, 2015 regarde si t as pas oublié de declarer la variable dans le module public $combinations; Link to comment Share on other sites More sharing options...
BusyBusy Posted September 9, 2015 Share Posted September 9, 2015 Pour ma part ça fonctionne comme ça : dans homefeatured.php public $combinations; public function getProductAttributeCombinations($products) { $combinations = array(); foreach($products as $product) { $product = new Product ($product['id_product'], $this->context->language->id); $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } et ensuite pour la fonction HookDisplayHome : public function hookDisplayHome($params) { if(!$products){ $products = HomeFeatured::$cache_products; $combinations = $this->getProductAttributeCombinations($products); $this->context->smarty->assign('combinations', $combinations); $this->_cacheProducts(); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'combinations' => $combinations, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } else { $products = $products; $combinations = $this->getProductAttributeCombinations($products); $this->context->smarty->assign('combinations', $combinations); $this->_cacheProducts(); $this->smarty->assign( array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'combinations' => $combinations, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId()); Salut cirylBD28 !! avec ton code j'ai enfin la variable $combinations dans ma console de debug maintenant reste à l'afficher dans le template j'ai ça {foreach from=$combinations key=k item=comb} {* because the array key are id_product, we can separate the product combinations in here with if/else statement compared with the id_product from the foreach loop of products-list *} {if $products.id_product == $k} {* The attribute Group Name *} <p class="comb_title">{$comb.group_name}</p> {* List of attribute values inside the attribute Group for current product *} <select> {foreach from=$comb item=attr} <option value="{$attr.id_attribute}">{$attr.attribute_name} {l s=': +'} {convertPrice price=$attr.unit_price_impact}</option> {/foreach} </select> {/if} {/foreach} Link to comment Share on other sites More sharing options...
cirylBD28 Posted September 9, 2015 Share Posted September 9, 2015 (edited) Allez va, le code pour product-list... {if ($product.id_product_attribute!='0')} <div class="a_partir_de"> {foreach from=$combinations key=k item=comb} {if $product.id_product == $k} {foreach from=$comb item=attr} {if $attr.default_on =='1'} <p><span class="attname"> <span class="mobile_att">{assign var="attname" value=$attr.attribute_name} {assign var="bar_at" value=$attname|strpos:"("} {$attname|substr:0:$bar_at}<br /></span> ({$attname|substr:($attname|strpos:"("+1)}</span></p> {/if} {/foreach} {/if} {/foreach} </div> {else} <div class="a_partir_de"> <span class="attname2"><p>le lot</p></span> </div> {/if} à modifier quelque peu car j'avais faits des modifs en fonction de mon shop et pour notamment afficher la décli par défaut Si tu veux voir le rendu, tu peux faire un tour sur mon site : http://boucherie-dynamique.com Edited September 9, 2015 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
BusyBusy Posted September 9, 2015 Share Posted September 9, 2015 Allez va, le code pour product-list... {if ($product.id_product_attribute!='0')} <div class="a_partir_de"> {foreach from=$combinations key=k item=comb} {if $product.id_product == $k} {foreach from=$comb item=attr} {if $attr.default_on =='1'} <p><span class="attname"> <span class="mobile_att">{assign var="attname" value=$attr.attribute_name} {assign var="bar_at" value=$attname|strpos:"("} {$attname|substr:0:$bar_at}<br /></span> ({$attname|substr:($attname|strpos:"("+1)}</span></p> {/if} {/foreach} {/if} {/foreach} </div> {else} <div class="a_partir_de"> <span class="attname2"><p>le lot</p></span> </div> {/if} à modifier quelque peu car j'avais faits des modifs en fonction de mon shop et pour notamment afficher la décli par défaut Si tu veux voir le rendu, tu peux faire un tour sur mon site : http://boucherie-dynamique.com Salut merci beaucoup pour l'aide mais je viens de me rendre compte que $combinations sortait rien dans le tableau donc je pense qu'il faut que je modifie la variable dans le homefeatured.php je vous en redis plus dès que j'ai trouvé ^^ merci beaucoup pour le temps que vous consacrez à mon pb Link to comment Share on other sites More sharing options...
BusyBusy Posted September 9, 2015 Share Posted September 9, 2015 Re, quand je fais un var_dump comme ceci {if isset($combinations)} {$combinations|@var_dump} {/if} j'obtiens : <pre class="xdebug-var-dump" dir="ltr"> <b>array</b> <i>(size=0)</i> <i> </pre> je ne sais pas trop comment trouver la solution car j'ai retourné le pb dans tous les sens et j'ai rien trouvé Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 Et bien, après plusieurs heures de recherche toujours rien ... $combinations est vide ! Link to comment Share on other sites More sharing options...
cirylBD28 Posted September 10, 2015 Share Posted September 10, 2015 (edited) Et bien, après plusieurs heures de recherche toujours rien ... $combinations est vide ! Tu as bien mis la fonction dans categoryController ? Mon override de CategoryController si ça peut t'aider : <?php /* function to get all necessary data of products combinations * @param $products An array of products data * return array products combinations */ class CategoryController extends CategoryControllerCore { public $php_self = 'category'; protected $category; protected $ajax_refresh = false; public $customer_access = true; public $combinations; public function getProductAttributeCombinations($products) { $combinations = array(); foreach($products as $product) { $product = new Product ($product['id_product'], $this->context->language->id); $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } /** * Set default medias for this controller */ public function setMedia() { parent::setMedia(); if ($this->context->getMobileDevice() == false) { //TODO : check why cluetip css is include without js file $this->addCSS(array( _THEME_CSS_DIR_.'scenes.css' => 'all', _THEME_CSS_DIR_.'category.css' => 'all', _THEME_CSS_DIR_.'product_list.css' => 'all', )); if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0) $this->addJS(_THEME_JS_DIR_.'products-comparison.js'); /*ajout gaelle*/ $this->addJS(array( _THEME_JS_DIR_.'category.js' )); /*fin ajout gaelle*/ } } public function canonicalRedirection($canonicalURL = '') { if (Tools::getValue('live_edit')) return; if (!Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop() || in_array($this->category->id, array(Configuration::get('PS_HOME_CATEGORY'), Configuration::get('PS_ROOT_CATEGORY')))) { $this->redirect_after = '404'; $this->redirect(); } if (!Tools::getValue('noredirect') && Validate::isLoadedObject($this->category)) parent::canonicalRedirection($this->context->link->getCategoryLink($this->category)); } /** * Initialize category controller * @see FrontController::init() */ public function init() { // Get category ID $id_category = (int)Tools::getValue('id_category'); if (!$id_category || !Validate::isUnsignedId($id_category)) $this->errors[] = Tools::displayError('Missing category ID'); // Instantiate category $this->category = new Category($id_category, $this->context->language->id); parent::init(); //check if the category is active and return 404 error if is disable. if (!$this->category->active) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); } //check if category can be accessible by current customer and return 403 if not if (!$this->category->checkAccess($this->context->customer->id)) { header('HTTP/1.1 403 Forbidden'); header('Status: 403 Forbidden'); $this->errors[] = Tools::displayError('You do not have access to this category.'); $this->customer_access = false; } } public function initContent() { parent::initContent(); $products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); $combinations = $this->getProductAttributeCombinations($products); $this->context->smarty->assign('combinations', $combinations); if(isset($_POST["envoi"])){ for($i=1;$i<=(int)$_POST['total_var'];$i++){ if((int)$_POST['nb_'.$i]!=0){ //$context = new Context(); if (!$this->context->cart->id) { $this->context->cart->add(); if ($this->context->cart->id) $this->context->cookie->id_cart = (int)$this->context->cart->id; } $cart = new Cart($this->context->cookie->id_cart); $cart->updateQty((int)$_POST['nb_'.$i], (int)$_POST['id_product'.$i]); //echo $link->getPageLink('order'); /*if (!$this->context->cart->id) { $this->context->cart->add(); if ($this->context->cart->id) $this->context->cookie->id_cart = (int)$this->context->cart->id; }*/ //$cart_rules = $this->context->cart->getCartRules(); //$this->context->cart->updateQty($_POST['nb_'.$i], $_POST['id_product'.$i]); //$cart_rules2 = $this->context->cart->getCartRules(); /*if (count($cart_rules2) != count($cart_rules)) $this->ajax_refresh = true; else { $rule_list = array(); foreach ($cart_rules2 as $rule) $rule_list[] = $rule['id_cart_rule']; foreach ($cart_rules as $rule) if (!in_array($rule['id_cart_rule'], $rule_list)) { $this->ajax_refresh = true; break; } }*/ } } $link=new Link(); header('Location:'.$link->getPageLink('order')); } $this->setTemplate(_PS_THEME_DIR_.'category.tpl'); if (!$this->customer_access) return; if (isset($this->context->cookie->id_compare)) $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare)); $this->productSort(); // Product sort must be called before assignProductList() $this->assignScenes(); $this->assignSubcategories(); if ($this->category->id != 1) $this->assignProductList(); //if ($this->level_depth==4) { $others=$this->category->getOthersCategories($this->context->language->id); //} $this->context->smarty->assign(array( 'category' => $this->category, 'products' => (isset($this->cat_products) && $this->cat_products) ? $this->cat_products : null, 'id_category' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'combinations' => $combinations, 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize(ImageType::getFormatedName('category')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'thumbSceneSize' => Image::getSize(ImageType::getFormatedName('m_scene')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'allow_oosp' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int)Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers(), 'others_categories' => $others )); } /** * Assign scenes template vars */ protected function assignScenes() { // Scenes (could be externalised to another controler if you need them) $scenes = Scene::getScenes($this->category->id, $this->context->language->id, true, false); $this->context->smarty->assign('scenes', $scenes); // Scenes images formats if ($scenes && ($sceneImageTypes = ImageType::getImagesTypes('scenes'))) { foreach ($sceneImageTypes as $sceneImageType) { if ($sceneImageType['name'] == ImageType::getFormatedName('m_scene')) $thumbSceneImageType = $sceneImageType; elseif ($sceneImageType['name'] == ImageType::getFormatedName('scene')) $largeSceneImageType = $sceneImageType; } $this->context->smarty->assign(array( 'thumbSceneImageType' => isset($thumbSceneImageType) ? $thumbSceneImageType : null, 'largeSceneImageType' => isset($largeSceneImageType) ? $largeSceneImageType : null, )); } } /** * Assign sub categories templates vars */ protected function assignSubcategories() { if ($subCategories = $this->category->getSubCategories($this->context->language->id)) { $this->context->smarty->assign(array( 'subcategories' => $subCategories, 'subcategories_nb_total' => count($subCategories), 'subcategories_nb_half' => ceil(count($subCategories) / 2) )); } } /** * Assign list of products template vars */ public function assignProductList() { $hookExecuted = false; Hook::exec('actionProductListOverride', array( 'nbProducts' => &$this->nbProducts, 'catProducts' => &$this->cat_products, 'hookExecuted' => &$hookExecuted, )); // The hook was not executed, standard working if (!$hookExecuted) { $this->context->smarty->assign('categoryNameComplement', ''); $this->nbProducts = $this->category->getProducts(null, null, null, $this->orderBy, $this->orderWay, true); $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts" $this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); } // Hook executed, use the override else // Pagination must be call after "getProducts" $this->pagination($this->nbProducts); foreach ($this->cat_products as &$product) { if ($product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity'])) $product['minimal_quantity'] = $product['product_attribute_minimal_quantity']; } $this->context->smarty->assign('nb_products', $this->nbProducts); } } Edited September 10, 2015 by cirylBD28 (see edit history) Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 Salut, merci pour ton retour : j'ai pas de problème pour afficher $combinations dans category.tpl, mon override du controller category est bon... je pense que cela vient de homefeatured.php dont il manque certainement un truc ... je suis tellement une bille que je ne trouve pas ! Link to comment Share on other sites More sharing options...
cirylBD28 Posted September 10, 2015 Share Posted September 10, 2015 Tu peux poster le code que tu as intégré dans homefeatured.php ? Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 Tu peux poster le code que tu as intégré dans homefeatured.php ? Tiens j'ai mis ça ici : http://codepad.org/cggLJbLU Link to comment Share on other sites More sharing options...
cirylBD28 Posted September 10, 2015 Share Posted September 10, 2015 je remarque que notamment ton getContent n'est pas le même que moi... Je te joins mon code complet pour Homefeatured <?php /* * 2007-2014 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) exit; class HomeFeatured extends Module { protected static $cache_products; public function __construct() { $this->name = 'homefeatured'; $this->tab = 'front_office_features'; $this->version = '1.6.4'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Featured products on the homepage'); $this->description = $this->l('Displays featured products in the central column of your homepage.'); } public function install() { $this->_clearCache('*'); Configuration::updateValue('HOME_FEATURED_NBR', 8); Configuration::updateValue('HOME_FEATURED_CAT', (int)Context::getContext()->shop->getCategory()); Configuration::updateValue('HOME_FEATURED_RANDOMIZE', false); if (!parent::install() || !$this->registerHook('header') || !$this->registerHook('addproduct') || !$this->registerHook('updateproduct') || !$this->registerHook('deleteproduct') || !$this->registerHook('categoryUpdate') || !$this->registerHook('displayHomeTab') || !$this->registerHook('displayHomeTabContent') ) return false; return true; } public function uninstall() { $this->_clearCache('*'); return parent::uninstall(); } public $combinations; public function getProductAttributeCombinations($products) { $combinations = array(); foreach($products as $product) { $product = new Product ($product['id_product'], $this->context->language->id); $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } public function getContent() { $output = ''; $errors = array(); if (Tools::isSubmit('submitHomeFeatured')) { $nbr = Tools::getValue('HOME_FEATURED_NBR'); if (!Validate::isInt($nbr) || $nbr <= 0) $errors[] = $this->l('The number of products is invalid. Please enter a positive number.'); $cat = Tools::getValue('HOME_FEATURED_CAT'); if (!Validate::isInt($cat) || $cat <= 0) $errors[] = $this->l('The category ID is invalid. Please choose an existing category ID.'); $rand = Tools::getValue('HOME_FEATURED_RANDOMIZE'); if (!Validate::isBool($rand)) $errors[] = $this->l('Invalid value for the "randomize" flag.'); if (isset($errors) && count($errors)) $output = $this->displayError(implode('<br />', $errors)); else { Configuration::updateValue('HOME_FEATURED_NBR', (int)$nbr); Configuration::updateValue('HOME_FEATURED_CAT', (int)$cat); Configuration::updateValue('HOME_FEATURED_RANDOMIZE', (bool)$rand); Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('homefeatured.tpl')); $output = $this->displayConfirmation($this->l('Your settings have been updated.')); } } return $output.$this->renderForm(); } public function hookDisplayHeader($params) { $this->hookHeader($params); } public function hookHeader($params) { if (isset($this->context->controller->php_self) && $this->context->controller->php_self == 'index') $this->context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css'); $this->context->controller->addCSS(($this->_path).'css/homefeatured.css', 'all'); } public function _cacheProducts() { if (!isset(HomeFeatured::$cache_products)) { $category = new Category((int)Configuration::get('HOME_FEATURED_CAT'), (int)Context::getContext()->language->id); $nb = (int)Configuration::get('HOME_FEATURED_NBR'); if (Configuration::get('HOME_FEATURED_RANDOMIZE')) HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), null, null, false, true, true, ($nb ? $nb : 8)); else HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), 'position'); } if (HomeFeatured::$cache_products === false || empty(HomeFeatured::$cache_products)) return false; } public function hookDisplayHomeTab($params) { if (!$this->isCached('tab.tpl', $this->getCacheId('homefeatured-tab'))) $this->_cacheProducts(); return $this->display(__FILE__, 'tab.tpl', $this->getCacheId('homefeatured-tab')); } public function hookDisplayHome($params) { if(!$products){ $products = HomeFeatured::$cache_products; $combinations = $this->getProductAttributeCombinations($products); $this->context->smarty->assign('combinations', $combinations); $this->_cacheProducts(); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'combinations' => $combinations, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } else { $products = $products; $combinations = $this->getProductAttributeCombinations($products); $this->context->smarty->assign('combinations', $combinations); $this->_cacheProducts(); $this->smarty->assign( array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'combinations' => $combinations, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId()); } public function hookDisplayHomeTabContent($params) { return $this->hookDisplayHome($params); } public function hookAddProduct($params) { $this->_clearCache('*'); } public function hookUpdateProduct($params) { $this->_clearCache('*'); } public function hookDeleteProduct($params) { $this->_clearCache('*'); } public function hookCategoryUpdate($params) { $this->_clearCache('*'); } public function _clearCache($template, $cache_id = NULL, $compile_id = NULL) { parent::_clearCache('homefeatured.tpl'); parent::_clearCache('tab.tpl', 'homefeatured-tab'); } public function renderForm() { $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'description' => $this->l('To add products to your homepage, simply add them to the corresponding product category (default: "Home").'), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Number of products to be displayed'), 'name' => 'HOME_FEATURED_NBR', 'class' => 'fixed-width-xs', 'desc' => $this->l('Set the number of products that you would like to display on homepage (default: 8).'), ), array( 'type' => 'text', 'label' => $this->l('Category from which to pick products to be displayed'), 'name' => 'HOME_FEATURED_CAT', 'class' => 'fixed-width-xs', 'desc' => $this->l('Choose the category ID of the products that you would like to display on homepage (default: 2 for "Home").'), ), array( 'type' => 'switch', 'label' => $this->l('Randomly display featured products'), 'name' => 'HOME_FEATURED_RANDOMIZE', 'class' => 'fixed-width-xs', 'desc' => $this->l('Enable if you wish the products to be displayed randomly (default: no).'), 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Yes') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('No') ) ), ), ), 'submit' => array( 'title' => $this->l('Save'), ) ), ); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $this->fields_form = array(); $helper->id = (int)Tools::getValue('id_carrier'); $helper->identifier = $this->identifier; $helper->submit_action = 'submitHomeFeatured'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); return $helper->generateForm(array($fields_form)); } public function getConfigFieldsValues() { return array( 'HOME_FEATURED_NBR' => Tools::getValue('HOME_FEATURED_NBR', (int)Configuration::get('HOME_FEATURED_NBR')), 'HOME_FEATURED_CAT' => Tools::getValue('HOME_FEATURED_CAT', (int)Configuration::get('HOME_FEATURED_CAT')), 'HOME_FEATURED_RANDOMIZE' => Tools::getValue('HOME_FEATURED_RANDOMIZE', (bool)Configuration::get('HOME_FEATURED_RANDOMIZE')), ); } } Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 (edited) Comme je te l'ai dit hier il faut que tu déclares la variable $combinations; dans ton module. class HomeFeatured extends Module { public $combinations; protected static $cache_products; public function __construct() { $this->name = 'homefeatured'; $this->tab = 'front_office_features'; $this->version = '1.4'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Featured products on the homepage'); $this->description = $this->l('Displays featured products in the central column of your homepage.'); } Je remarque qu'elle est declaré après la fonction ... Edited September 10, 2015 by Alexandre-KM (see edit history) Link to comment Share on other sites More sharing options...
cirylBD28 Posted September 10, 2015 Share Posted September 10, 2015 Comme je te l'ai dit hier il faut que tu déclares la variable $combinations; dans ton module. class HomeFeatured extends Module { public $combinations; protected static $cache_products; public function __construct() { $this->name = 'homefeatured'; $this->tab = 'front_office_features'; $this->version = '1.4'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Featured products on the homepage'); $this->description = $this->l('Displays featured products in the central column of your homepage.'); } Il l'a bien déclarée (juste au-dessus de hookDisplayHome) Link to comment Share on other sites More sharing options...
cirylBD28 Posted September 10, 2015 Share Posted September 10, 2015 Il l'a bien déclarée (juste au-dessus de hookDisplayHome) Par contre pas déclarée au bon endroit... Tu t'en sers dans ta fonction juste au-dessus de ta déclaration. Comme le montre alex, place là tout en haut Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 Je remarque qu'elle est declaré après la fonction ... 1 Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 Je remarque qu'elle est declaré après la fonction ... Bon j'ai tenu compte de vos remarques, mais rien ne change, tjrs cette variable vide ça commence à me prendre le choux ! J'ai tout remis dans l'ordre, vérifé (comme je pouvais, je ne suis pas un expert) mon code et je sèche... merci pour le temps que vous consacrez à ça !! Link to comment Share on other sites More sharing options...
cirylBD28 Posted September 10, 2015 Share Posted September 10, 2015 T'as essayé avec mon code complet de homefeatured ? Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 T'as essayé avec mon code complet de homefeatured ? Oui j'ai essayé et ça change rien ... vous pensez que cela pourrait venir de mon serveur ? Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 Active la console debug:dans ton footer.tpl tu inseres: {if isset($smarty.get.DEBUG)} {debug} {/if} avant la clôture du body </body> Ensuite tu vas dans performance et tu actives deplacer le javascript a la fin. Maintenant a la fin de ton url tu ajoutes http://www.monsite.com/?DEBUG Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 (edited) dans le pop up tu recherches $combinations et tu nous fait une capture Edited September 10, 2015 by Alexandre-KM (see edit history) Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 dans le pop up tu recherches $combinations et tu nous fait une capture http://www.hostingpics.net/viewer.php?id=604950combinations.jpg Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 Ok donc la variable $combination existe sauf que tu tombes sur un array.Il faut voir comment est fait la fonction "getProductAttributeCombinations": $combinations = $this->getProductAttributeCombinations($products); Postes nous ton override de Categorie.php ou la classes ou se trouve cette function: Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 Alors voici mon override de CategoryController.php public function getProductAttributeCombinations($products) { $combinations = array(); foreach($products as $product) { // load product object $product = new Product ($product['id_product'], $this->context->language->id); // get the product combinations data // create array combinations with key = id_product $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; } public function initContent() { parent::initContent(); $this->assignSubcategoriesAlt(); $products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); $combinations = $this->getProductAttributeCombinations($products); $this->context->smarty->assign(array( 'category' => $this->category, 'products' => (isset($this->cat_products) && $this->cat_products) ? $this->cat_products : null, 'id_category' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'combinations' => $combinations, 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize(ImageType::getFormatedName('category')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'thumbSceneSize' => Image::getSize(ImageType::getFormatedName('m_scene')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'allow_oosp' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int)Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers(), 'others_categories' => $others )); } Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 (edited) est ce que tu arrives a avoir le liste des combinaisons dans tes pages category / product list ? Edited September 10, 2015 by Alexandre-KM (see edit history) Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 Oui "tout marche bien navette" dans mes product list... Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 essaye dans homefeatured.php $combinations = homefeatured::getProductAttributeCombinations($products); Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 essaye dans homefeatured.php $combinations = homefeatured::getProductAttributeCombinations($products); à quel niveau ? parce que je suis un branque en php ^^ Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 (edited) public function hookDisplayHome($params) { if(!$products){ $products = HomeFeatured::$cache_products; $combinations = HomeFeatured::getProductAttributeCombinations($products); //ici $this->context->smarty->assign('combinations', $combinations); $this->_cacheProducts(); $this->smarty->assign( array( 'products' => HomeFeatured::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'combinations' => $combinations, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } else { $products = HomeFeatured::$cache_products; $combinations = HomeFeatured::getProductAttributeCombinations($products); $this->context->smarty->assign('combinations', $combinations); $this->_cacheProducts(); $this->smarty->assign( array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'combinations' => $combinations, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId()); } Edited September 10, 2015 by Alexandre-KM (see edit history) Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 recrée la function dans homefeatured.php /* 256: * Get product combinations 257: */ 258: public static function getProductAttributeCombination($id_product_attribute, $id_lang) 259: { 260: $sql = ' 261: SELECT al.`name` AS attribute_name 262: FROM `'._DB_PREFIX_.'product_attribute_combination` pac 263: LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`) 264: LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`) 265: LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.') 266: LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.') 267: LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`) 268: '.Shop::addSqlAssociation('product_attribute', 'pa').' 269: WHERE pac.`id_product_attribute` = '.(int)$id_product_attribute; 270: 271: return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); 272: } Link to comment Share on other sites More sharing options...
BusyBusy Posted September 10, 2015 Share Posted September 10, 2015 Bon, je crois que c'est peine perdue je vais faire appel à un pro pour faire la manip. Rien ne fonctionne comme prévu !!!! Link to comment Share on other sites More sharing options...
Alexandre Carette Posted September 10, 2015 Share Posted September 10, 2015 bon courage Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now