hixamail Posted July 11, 2016 Share Posted July 11, 2016 Hi, I'm trying to show a block on the category page that lists all products from the current category. I have tried to adapt the blocknewproducts module but don't know where to start. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2016 Share Posted July 13, 2016 It should be pretty easy to get all the products from the current category. Try the following: $products = array(); $category = new Category((int)Tools::getValue('id_category')); if (Validate::isLoadedObject($category)) { $products = $category->getProducts($this->context->language->id, 0, 1000, 'position', 'asc'); } This will get the first 1000 products from the current category and sort them by position. You can change 1000 to any number that's greater than the maximum number of products you have in a category. Note that loading too many products will cause the page to load slowly or even crash, so choose a number carefully. 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