desgnl Posted April 28, 2015 Share Posted April 28, 2015 Bonjour, Je souhaiterai développer un module pour afficher des produits associés sur la fiche produit. L'idée, c'est de selectionner aléatoirement X produits parmi ceux qui ont les mêmes mots-clés. J'aimerais donc afficher le template product-list.tpl en fonction de cette requête. Pourriez-vous m'indiquer des pistes sur la manière de procéder ? merci Link to comment Share on other sites More sharing options...
J. Danse Posted April 28, 2015 Share Posted April 28, 2015 Bonsoir, Parmi ceux qui ont exactement les mêmes mots clés définis dans la section correspondante, c'est bien ça ? 1 Link to comment Share on other sites More sharing options...
desgnl Posted April 28, 2015 Author Share Posted April 28, 2015 (edited) par exemple: le produit de la page consulté a les mots-clés: "rock'n roll", "casual" et "preppy" sur la page de ce produit, on va afficher N produits associés (avec le template product-list.tpl) parmi ceux qui ont au moins un des mots-clés. (idéalement, on pourrait choisir N dans l'interface d'admin) Edited April 28, 2015 by desgnl (see edit history) Link to comment Share on other sites More sharing options...
J. Danse Posted April 28, 2015 Share Posted April 28, 2015 Voici un petit cadeau du mardi soir similarkeywords-v1.0.0.zip 1 Link to comment Share on other sites More sharing options...
desgnl Posted April 29, 2015 Author Share Posted April 29, 2015 merci maitre ! c'est vraiment super cool ! je vais essayer de fignoler 2 petits trucs: • exclure le produit consulté de la liste des résultats • afficher le nom du produit, le prix etc. merci merci MERCI ! Link to comment Share on other sites More sharing options...
J. Danse Posted April 29, 2015 Share Posted April 29, 2015 Avec plaisir. Exact, ce serait une ou l'autre amélioration à faire. La partie suivante dans le code: $product['out_of_stock'] = ''; $product['id_category_default'] = ''; $product['id_supplier'] = 0; $product['available_for_order'] = ''; $cover = Product::getCover((int)$product['id_product']); $product['id_image'] = (int)$cover['id_image']; $link_rewrite_informations = Product::getUrlRewriteInformations((int)$product['id_product']); $product['link_rewrite'] = ''; $product['ean13'] = ''; foreach ($link_rewrite_informations as $link_rewrite_information) if ((int)$link_rewrite_information['id_lang'] == (int)$this->context->language->id) { $product['link_rewrite'] = $link_rewrite_information['link_rewrite']; $product['ean13'] = $link_rewrite_information['ean13']; } $product = Product::getProductProperties((int)$this->context->language->id, $product); est celle à traitée tout particulièrement, en gros ;-) 1 Link to comment Share on other sites More sharing options...
J. Danse Posted April 29, 2015 Share Posted April 29, 2015 (edited) Pour la partie d'exclure le produit de la liste: Il faut remplacer ceci: foreach ($associated_products as $associated_product) $products[$associated_product['id_product']] = $associated_product; Par ceci: foreach ($associated_products as $associated_product) { if ((int)$associated_product['id_product'] != $params['product']->id) $products[$associated_product['id_product']] = $associated_product; } Edited April 29, 2015 by J. Danse (see edit history) 1 Link to comment Share on other sites More sharing options...
desgnl Posted April 29, 2015 Author Share Posted April 29, 2015 Link to comment Share on other sites More sharing options...
desgnl Posted April 29, 2015 Author Share Posted April 29, 2015 est ce qu'il y a un moyen d'assigner directement toutes les propriétés d'un produits ? (par exemple quand j'affiche {$product} sur la page category, il y a tout ça: ( [id_product] => 115 [id_category_default] => 3 [id_shop_default] => 1 [id_tax_rules_group] => 1 [on_sale] => 0 [online_only] => 0 [ean13] => [upc] => [ecotax] => 0.000000 [quantity] => 0 [minimal_quantity] => 1 [price] => 165 [wholesale_price] => 0.000000 [unity] => [unit_price_ratio] => 0.000000 [additional_shipping_cost] => 0.00 [reference] => aw14.5-shoes-dickinson-naturel [supplier_reference] => [location] => [width] => 30.000000 [height] => 15.000000 [depth] => 30.000000 [weight] => 1.000000 [out_of_stock] => 2 [quantity_discount] => 0 [customizable] => 0 [uploadable_files] => 0 [text_fields] => 0 [active] => 1 [redirect_type] => 404 [id_product_redirected] => 0 [available_for_order] => 1 [available_date] => 0000-00-00 [condition] => new [show_price] => 1 [indexed] => 1 [visibility] => both [cache_is_pack] => 0 [cache_has_attachments] => 0 [is_virtual] => 0 [cache_default_attribute] => 437 [date_add] => 2015-02-12 11:17:09 [date_upd] => 2015-04-22 16:16:41 [advanced_stock_management] => 0 [pack_stock_type] => 3 [id_shop] => 1 [id_lang] => 1 [description] => [description_short] => bla bla. [link_rewrite] => dickinson-naturel [meta_description] => [meta_keywords] => [meta_title] => [name] => Dickinson Naturel [available_now] => [available_later] => [id_image] => 115-316 [legend] => [manufacturer_name] => [id_product_attribute] => 437 [new] => 0 [allow_oosp] => 0 [category] => chaussures [link] => http://le-lien.com/le-produit [attribute_price] => 0 [price_tax_exc] => 137.5 [price_without_reduction] => 275 [reduction] => 91.666667 [specific_prices] => Array ( [id_specific_price] => 521 [id_specific_price_rule] => 0 [id_cart] => 0 [id_product] => 115 [id_shop] => 0 [id_shop_group] => 0 [id_currency] => 0 [id_country] => 0 [id_group] => 0 [id_customer] => 0 [id_product_attribute] => 0 [price] => -1.000000 [from_quantity] => 1 [reduction] => 0.400000 [reduction_tax] => 1 [reduction_type] => percentage [from] => 0000-00-00 00:00:00 [to] => 0000-00-00 00:00:00 [score] => 0 ) [quantity_all_versions] => 7 [features] => Array ( [0] => Array ( [name] => feature 1 [value] => bal [id_feature] => 1 ) [1] => Array ( [name] => feature 2 [value] => 4 cm [id_feature] => 2 ) ) [attachments] => Array ( ) [virtual] => 0 [pack] => 0 [packItems] => Array ( ) [nopackprice] => 0 [customization_required] => [rate] => 20 [tax_name] => TVA FR 20% [color_list] => ) Link to comment Share on other sites More sharing options...
J. Danse Posted April 29, 2015 Share Posted April 29, 2015 Malheureusement, non. En fait, il y a déjà une bonne partie qui l'est via le getProductProperties. Mais une autre bonne partie est traitée par la méthode de récupération des produits d'une catégories, notamment. :-/ 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