In catalog/product/list.phtml
, how can I always use the products from a single, saved product collection?
Is there a way to load a product collection, save it, then show some of these products (e.g. 20) per page without having to reload the product collection again when a new page is reached (either clicked or in infinite scrolling)?
I considered a couple of ways, but my understanding falls way short.
Create an observer which filters out any products that have already appeared.
//catalog_product_collection_load_before $productCollection = $observer->getEvent()->getCollection(); $currentPage = (int) Mage::App()->getRequest()->getParam('p'); $seen = array(); foreach($productCollection as $item){ // getting 503 on page 2 $seen[] = $item->getId(); } $productCollection->clear(); $productCollection->addAttributeToFilter('entity_id', array('nin' => $seen)); $productCollection->setCurPage($currentPage)->setPageSize(20);
Some kind of controller (indexAction)
$productsCollection->setCurPage($currentPage); $productsCollection->load(); foreach ($productsCollection as $_product) { // ??? } $currentPage++; $productsCollection->clear();
Of course these are just fragments. Any pointers would be much appreciated.