bnthor Posted April 26, 2016 Share Posted April 26, 2016 (edited) Bonjour, Je cherche le moyen de compter les attributs (ex. taille/couleur) de chaques produit sur ma page liste, plus précisement de savoir si un produit a un attribut au moins. J'ai essayé avec smarty {$product.attributes|@count}, mais ça me retourne 1 pour chaque produit, même ceux qui n'ont aucune déclinaison. Ensuite j'ai essayé $product.hasAttributes sans succès... Merci d'avance, je suis perdu Edited April 26, 2016 by bnthor (see edit history) Link to comment Share on other sites More sharing options...
bnthor Posted April 28, 2016 Author Share Posted April 28, 2016 Je me répond tout seul après avoir trouvé la solution sur Stack overflow. En espérant que ça aide qqun...Il faut ajouter une fonction à la fin de ./config/config.inc.php : function count_product_combinations($id_product) { $product = new Product($id_product); return count($product->getAttributeCombinaisons(Context::getContext()->language->id)); } et dans vos .tpl vous pouvez l'utiliser comme ceci : {if count_product_combinations($product.id_product) > 1} {* Mon code *} {/if} merci au revoir 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