facbest Posted March 25, 2014 Share Posted March 25, 2014 (edited) Bonjour, Quelqu'un aurait il une idée comment faire les produits phares aléatoires sur la version de prestashop 1.6. Sur la 1.5 ce code marche mais pas sur la 1.6 $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10),NULL,NULL,false,true,true,($nb ? $nb : 50)); Voici le code à modifier : public function _cacheProducts() { if (!isset(HomeFeatured::$cache_products)) { $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id); $nb = (int)Configuration::get('HOME_FEATURED_NBR'); 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; } Merci par avance .. Edited March 25, 2014 by facbest (see edit history) Link to comment Share on other sites More sharing options...
utaku Posted March 31, 2014 Share Posted March 31, 2014 Je rejoint facbest, si quelqu'un à une idée ... Link to comment Share on other sites More sharing options...
facbest Posted March 31, 2014 Author Share Posted March 31, 2014 (edited) Bonjour, La solution ! if (!isset(HomeFeatured::$cache_products)) { $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id); $nb = (int)Configuration::get('HOME_FEATURED_NBR'); HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 50),NULL,NULL,false,true,true,($nb ? $nb : 8), 'position'); /*$cache_products = range(8, 50); shuffle($cache_products);*/ } Ne pas oublier de vider le cache. Dommage pour les fautes au titre .... Edited March 31, 2014 by facbest (see edit history) Link to comment Share on other sites More sharing options...
dreamlove Posted March 31, 2014 Share Posted March 31, 2014 Bonjour merci pour cette info , mais quel fichier doit ont modifier Cordialement Link to comment Share on other sites More sharing options...
facbest Posted March 31, 2014 Author Share Posted March 31, 2014 Le fichier modules/homefeatured/homefeatured.php ligne : 118 Link to comment Share on other sites More sharing options...
dreamlove Posted March 31, 2014 Share Posted March 31, 2014 Merci Link to comment Share on other sites More sharing options...
utaku Posted March 31, 2014 Share Posted March 31, 2014 Bonjour, Merci pour cette astuce, serait-il possible de faire de même pour les nouveaux produits? celui qui se retrouve en page d'accueil ? Bien à vous Link to comment Share on other sites More sharing options...
CharlyAes32 Posted April 7, 2014 Share Posted April 7, 2014 Bonjour, La solution ! if (!isset(HomeFeatured::$cache_products)) { $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id); $nb = (int)Configuration::get('HOME_FEATURED_NBR'); HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 50),NULL,NULL,false,true,true,($nb ? $nb : 8), 'position'); /*$cache_products = range(8, 50); shuffle($cache_products);*/ } Ne pas oublier de vider le cache. Dommage pour les fautes au titre .... Pour moi, ça marche pas... Je vide le cache, ca marche 1 fois et si j'actualise la page, ca marche plus. J'ai toujours les mêmes produits. Link to comment Share on other sites More sharing options...
facbest Posted April 7, 2014 Author Share Posted April 7, 2014 C'est normal que ça marche q'une fois il faut vider le cache à chaque fois pour voir le changement. Désactivé le cache dans le back office et cela va marcher à chaque fois. Link to comment Share on other sites More sharing options...
CharlyAes32 Posted April 7, 2014 Share Posted April 7, 2014 C'est normal que ça marche q'une fois il faut vider le cache à chaque fois pour voir le changement. Désactivé le cache dans le back office et cela va marcher à chaque fois. Merci !!! C'est vrai qu'étant en local pour les modifs, j'avais oublié de le désactiver Link to comment Share on other sites More sharing options...
kokoon Posted April 8, 2014 Share Posted April 8, 2014 Bonjour, Si j'ai bien comprit il faut remplacer la ligne : HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), 'position'); par celle-ci : HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 50),NULL,NULL,false,true,true,($nb ? $nb : 8), 'position'); Cela fonctionne mais pour être certain y'a rien d'autre à modifier/supprimer ? Link to comment Share on other sites More sharing options...
facbest Posted April 8, 2014 Author Share Posted April 8, 2014 Non ! Link to comment Share on other sites More sharing options...
kokoon Posted April 8, 2014 Share Posted April 8, 2014 Non quoi ? je me trompe ou bien non y'a rien d'autre à modifier ? Link to comment Share on other sites More sharing options...
antikiste Posted April 8, 2014 Share Posted April 8, 2014 Ce serait pas possible de garder 1 produit phare fixe et les 3 autres en rotation autour de l'attaquant ? Désolé j'suis dans le match de ce soir.. 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