Display magento products by category ID


Universal Coder

<?php
$categoryIds = array(18);//category id

$collection = Mage::getModel('catalog/product')
->getCollection()
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
->addAttributeToSelect('*')
->addAttributeToFilter('category_id', array('in' => $categoryIds))
$_collectionSize = $collection->count()
?>

Get detail of products

<ul>
<?php $i=0; foreach ($collection as $_product):  ?>
<?php $i++;?>
<?php if($i!=4){ // for maximum 3 product ?>
<li>
init($_product, 'small_image')->resize(); ?>" />
currency($_product->getPrice(),true,false);?>
truncate($product->getShortDescription(), $length = 50, $etc = '...', $remainder = '', $breakWords = true); // word limit for short description ?>
</li> <?php } else{break;}?> <?php endforeach ?> </ul>

View original post

Advertisements
About

myself pramodh kumar yet another php developer from India and have worked on oops,procedural,yii framework,codeigniter,wordpress,joomla,api and more.

Tagged with: , , ,
Posted in php

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow php tutorial on WordPress.com
categories
Calendar
May 2014
M T W T F S S
« Apr   Jun »
 1234
567891011
12131415161718
19202122232425
262728293031  
Follow me on Twitter
Blog Stats
  • 72,886 hits
%d bloggers like this: