I am trying to limit the number of products from a certain category to 4 on my homepage.
The code I am trying to do this with is:
{{block type="catalog/product_list" column_count="4" category_id="13" template="catalog/product/list.phtml"}}
Here are some of the things I have tried:
num_products="4"
limit = 4, limit="4"
count = 4, count="4"
_productCollection="4"
_productsCount="4"
I have made a copy of list.phtml thinking there might be a way to change it in there, but was unable to find out a way.
At the very top pf list.phtml is this code:
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>
And under grid view there is this:
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
Any ideas on to limit the products either within the block or the template file?
The quicker is replace column_count=4
by is_homepage=1
and in the phtml add this :
<?php if($this->getIsHomepage() && $i==4) break; ?>
before this :
<?php if ($i++%$_columnCount==0): ?>
Then you will have just 1 row on homepage (if 4 by row as I suppose) so total 4 products
Try
{{block type="catalog/product_list" limit="4" category_id="13" template="catalog/product/list.phtml"}}
See
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With