I've created my Admin Page Grid but there is a strange issue when I try to prepare the collection. This is the code:
protected function _prepareCollection()
{
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->addAttributeToSort('entity_id', 'desc');
$collection->getSelect()->limit(5,1);
$this->setCollection($collection);
return parent::_prepareCollection();
}
and this the result:
I've try to limit the result to 5 items but it is ignored. The system gets 740 items. The query generated seems to be right:
SELECT `e`.*, `at_visibility`.`value` AS `visibility` FROM `catalog_product_entity` AS `e` INNER JOIN `catalog_product_entity_int` AS `at_visibility` ON (`at_visibility`.`entity_id` = `e`.`entity_id`) AND (`at_visibility`.`attribute_id` = '102') AND (`at_visibility`.`store_id` = 0) WHERE (at_visibility.value = '4') ORDER BY `e`.`entity_id` desc LIMIT 5 OFFSET 1
I've covered the if the method return $this instead of parent::_prepareCollection(), I obtain the right items but in the Pager area I continue to see "Total 740 records found".
Where am I wrong?