hurraken Posted March 11, 2011 Posted March 11, 2011 Hello,I'd like to know if there's a way to display the items of the new products block by add date DESC iso ID.Thank you for your (fast) replies.Regards. Share this post Link to post Share on other sites More sharing options...
MrBaseball34 Posted March 11, 2011 Posted March 11, 2011 Change this code in blocknewproducts.php: $newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR')); to this: $newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR'), false, 'date_add', 'DESC'); Now, while I was going to post the code above, I found this. In Product::getNewProducts(), I see this code: if (empty($orderBy) || $orderBy == 'position') $orderBy = 'date_add'; if (empty($orderWay)) $orderWay = 'DESC'; Which leads me to think that it defaults to date_add DESC.How is yours coming up, anyway? What version of PS are you using? Share this post Link to post Share on other sites More sharing options...
hurraken Posted March 11, 2011 Posted March 11, 2011 Hello MrBaseball34,Thank you very much for your reply.I made a mistake, i use HomeNewProducts from Prestacrea :The code is this one : function hookHome($params) { global $smarty, $cookie; $category = new Category(1); $nb = intval(Configuration::get('HOME_NEW_PRODUCTS_NBR')); $rand = intval(Configuration::get('HOME_NEW_PRODUCTS_RANDOM')); if ($rand == 1) { $products = Product::getNewProducts(intval($cookie->id_lang), 0, $nb); if ( $products ) { shuffle($products); array_splice($products, ($nb ? $nb : 10)); } } else { $products = Product::getNewProducts(intval($cookie->id_lang), NULL - 0, (intval($nb ? $nb : 4)), false, NULL, NULL); } I'm using Pretsashop 1.3.7Best regards Share this post Link to post Share on other sites More sharing options...
MrBaseball34 Posted March 12, 2011 Posted March 12, 2011 Here's what this code tells me: function hookHome($params) { global $smarty, $cookie; $category = new Category(1); Get configuration parameters: $nb = intval(Configuration::get('HOME_NEW_PRODUCTS_NBR')); $rand = intval(Configuration::get('HOME_NEW_PRODUCTS_RANDOM')); If you want random new products, get the list of new products and shuffle them in a random order. if ($rand == 1) { $products = Product::getNewProducts(intval($cookie->id_lang), 0, $nb); if ( $products ) { shuffle($products); array_splice($products, ($nb ? $nb : 10)); } otherwise, get the regular list of products in date_add DESC order. } else { $products = Product::getNewProducts(intval($cookie->id_lang), NULL - 0, (intval($nb ? $nb : 4)), false, NULL, NULL); } } So, all you have to do is set the HOME_NEW_PRODUCTS_RANDOM to 0 in ps_configuration to make the items come outin the order you want. It is probably a configuration parameter in the module that you areusing. Share this post Link to post Share on other sites More sharing options...
cammo Posted June 19, 2011 Posted June 19, 2011 Do Prestacrea make a module to randomize the New Products Block?Or is there another solution? I'd like the New Products block to randomly show a different product on page load rather than the same one all the time!Or even better would be a JQuery sliding block to cycle through a few new products..Any suggestions? Share this post Link to post 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