Anyone know how to set offset in Magento products collection? I need to get 11 products on first collection page than on other pages I want to have 8 products, and I must know how many pages by 8 (with offset of 11) I have.
With a different number of products between the first page and other pages, you are probably going to find it's not entirely straightforward dealing the paging. When dealing with collections I like to fall back to the underlying Zend methods by pulling the select object from the collection:
$select = $collection->getSelect();
you can then run any Zend_Db_Select method to build the collection for each page including the
limit() which allows you set a limit on returned results and an offset, so you would need to use:
for the first page:
for the second page:
for the third page and so on. You will need to build some custom logic to calculate the offset for each page. Note that the page is not stored in the session so if there is no
$_GET argument you are on page 1, otherwise the argument indicates the current page.
Depending on how you are doing things you may need to use the
reset() method on the $select object to reset the limit/offset before you set your own. It's all on the Zend page linked above anyway.
As a final note, I would suggest only going down this road if you really have to, having different numbers of products on different category pages doesn't strike me as a great idea. There's always a better way to deal with a situation than going down a rather hacky route like this.