Magento – Get associated products of group in parts

collection;productproduct-collection

I need to load associate products in parts/portions.

I am showing 3 products default. After that I have added a link ("load more"). Once the user clicks on "load more", the next 3 products should be added in the table.

Maybe this could be DONE by Offset but how can I do this? I don't understand.

I don't know how I can get associate products collection.

Please help if any one know how I divide associated collection in parts/portions.

Below is my code

        $product = Mage::getModel('catalog/product');
$product->load('157902');
         $associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product)->setCurPage(2)->setPageSize(2);

But collection is empty when I used offset , current page or page size

Best Answer

This should do what you are looking for, setCurPage is the start of the Offset, and setPageSize is the number of items return starting from the offset:

$product = Mage::getModel('catalog/product');
$product->load('157902');
$_simples = Mage::getModel('catalog/product_type_grouped')->getAssociatedProductCollection($product)->setCurPage(0)->setPageSize(2);
foreach ($_simples as $key => $value) {
    Zend_Debug::dump($value->getEntityId());
}
Related Topic