ajnglagla Posted January 15, 2014 Share Posted January 15, 2014 (edited) Hello, I want to show latest items first in my homefeatured. I searched in forum i found a code, but it does not fit my code. Can you help me? This is original code: (what writes in forum) $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); . This is the code to show latest items first in homefeatured $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10) , 'id_product', 'desc'); . This is my code ... How should i change my code to show latest items first? $products = $category->getProducts((int)Context::getContext()->language->id, (int)($controller->p), (int)($controller->n), $controller->orderBy, $controller->orderWay); Edited January 15, 2014 by ajnglagla (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted January 15, 2014 Share Posted January 15, 2014 Try passing 'date_add' as 4th parameter $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10), 'date_add'); 1 Link to comment Share on other sites More sharing options...
NemoPS Posted January 15, 2014 Share Posted January 15, 2014 No, that shows products ordered by Id, it should be 'date_add' to be more representative (although ids are incremental) Link to comment Share on other sites More sharing options...
ajnglagla Posted January 15, 2014 Author Share Posted January 15, 2014 I want to see "Latest" first. But at the same time i have some products what i changed positions. What do you think, what is the best way to show latest first but not effect "moving one product to a different position" feature? Link to comment Share on other sites More sharing options...
NemoPS Posted January 15, 2014 Share Posted January 15, 2014 'date_add' Link to comment Share on other sites More sharing options...
ajnglagla Posted January 15, 2014 Author Share Posted January 15, 2014 Thank you i will try now Link to comment Share on other sites More sharing options...
ajnglagla Posted January 15, 2014 Author Share Posted January 15, 2014 I have changed my code $products = $category->getProducts((int)Context::getContext()->language->id, (int)($controller->p), (int)($controller->n), $controller->orderBy, $controller->orderWay); with this $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10), 'date_add'); But it didnt work. And the most interesting part is its loaded twice. I will show screenshot. Link to comment Share on other sites More sharing options...
ajnglagla Posted January 15, 2014 Author Share Posted January 15, 2014 Link to comment Share on other sites More sharing options...
ajnglagla Posted January 15, 2014 Author Share Posted January 15, 2014 I found a way.. I used 'DESC' instead of $controller->orderWay. Thank you Nemo1 and limon994 Link to comment Share on other sites More sharing options...
Recommended Posts