Apply limit on product collection retrieve from database
I am using Magento Enterprise edition 1.13.02. On a product listing page, I want to restrict the number of products fetch from database. For example, if particular category has 100 products, I want to set a limit of 50 and display only 50 products and toolbar and pagination should work as per 50 products count. Want to set a limit not on per page, but on whole collection where only 50 records will be fetched from database.
Did anyone get a chance to work on this and make it work successfully ?
Re: Apply limit on product collection retrieve from database
Thanks for reply.
Actually, Limit gets set by functions setPageSize() and limit(). Also limit is set on query and records we get are 50 from raw query
But in real time, Magento pagination works according to total products only, say 100.
I display 10 products per page, so total page numbers are 10 for 100 products. So after applying your solution and setting limit 50, total page number should be 5. But its not working like that, Magento loads a full collection and pagination shows 10 pages. However, as per our limit, only 50 products show but after 5 pages, products gets repeated like previous 5 pages. So on first 5 pages, first 50 products and on next 5 pages, same 50 products show.