kate66 Posted March 16, 2015 Share Posted March 16, 2015 (edited) Bonjour, je souhaite afficher directement la fiche produit si il n'en a qu'un produit dans la sous catégorie sélectionner dans le menu. c'est vraiment important. j'ai trouvé cela sur un forum mais cela ne change rien au site. Je l'ai mis a la place de getTree de la page blockcategorie.php: public function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0) { global $link, $cookie; $children = array(); if (isset($resultParents[$id_category]) AND sizeof($resultParents[$id_category]) AND ($maxDepth == 0 OR $currentDepth < $maxDepth)) foreach ($resultParents[$id_category] as $subcat) $children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); if (!isset($resultIds[$id_category])) return false; $cat = New Category($id_category); $nb_products = $cat-> getProducts($cookie->id_lang, 1, 10, NULL, NULL, true); // on récupère le nombre de produits de la catégorie if ($nb_products == 1) { //si le nombre de produits est égal à 1, on récupère le lien vers ce produit $prod_list = $cat-> getProducts($cookie->id_lang, 1, 10, NULL, NULL); $catlink = $link->getProductLink($prod_list[0]['id_product'], $prod_list[0]['link_rewrite']); } // sinon on retourne le lien vers la catégorie (comportement identique à celui d'origine) else $catlink = $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']); return array('id' => $id_category , 'link' => $catlink , 'name' => $resultIds[$id_category]['name'], 'desc'=> $resultIds[$id_category]['description'] , 'children' => $children , 'meta_title' => $resultIds[$id_category]['meta_title'] ); } merci. Edited March 16, 2015 by kate66 (see edit history) Link to comment Share on other sites More sharing options...
kate66 Posted March 17, 2015 Author Share Posted March 17, 2015 bonjour, personne n'a une petite idée? merci. 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