I have a list of 6 products that i want to split in 2 lists of 3 products next to each other. The list are made within a foreach loop, the first list stops after the count == 2, so 3 items wil be displayed. The second list should start with the fourth item. How can i achieve this?
This is wat makes the first list of 3 items:
<?php $_categoryId = explode(' ', $category['id']); $count = 0; $_productCollection = Mage::getModel('catalog/category')->load($_categoryId) ->getProductCollection() ->addAttributeToSelect('*') ->setOrder('date_added', 'DESC'); ?> <?php foreach ($_productCollection as $_product): ?> <li class="category-row-list-item"> <a class="product-name" href="<?php echo $_product->getProductUrl() ?>"> <?php echo $this->htmlEscape($_product->getName()) ?> </a> </li> <?php if($count == 2) break; // Stop after 3 items $count++; ?> <?php endforeach ?>
Best regards, Robert