Im trying to limit the number of returned results manually in a copy of the list.phtml template, but its turning out to be alot harder than I anticipated.
Ive tried man
unfortunately it doesn't work because in the _getProductCollection() method the Collection has been already initialized with a page size.
A more flexible solution could be that of observing the catalog_product_collection_load_before event which, as the name suggests, is dispatched before the collection is loaded.
Here follows an example (assuming to write a yourmodule extension under yourpackage):
STEP 1: Define your observer in config.xml
in the global section of your config.xml extension file insert something like:
singleton
yourpackage_yourmodule/catalog_observer
limitPageSize
STEP 2: Define your Observer class under the Model\Catalog folder:
getEvent();
$collection = $event->getCollection();
$collection->setPageSize(3);
return $this;
}
}
Hope it helps. Sincerely, Alessandro Ronchi