How to get products from categories in magento?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kaushal Elsner
    New Member
    • Jan 2011
    • 23

    How to get products from categories in magento?

    I want to display all the products from the individual categories. I am putting my code here that what i have done so far.

    Code:
    <?php
    	$_main_categories = $this->getStoreCategories();
    	
    	foreach ($_main_categories as $_main_category):
    ?>
    		<li>
    			<div style="width:593px;">
    			<?php
    				$_products = $_main_category->getProductCollection();
    				$i=0;
    				foreach ($_products->getItems() as $_product):
    					if($i<3)
    					{
    			?>
    						<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(80) ?>" />
    			<?php
    					}
    				$i++;
    				endforeach
    			?>
    			</div>
    		
    			<div class="lof-main-item-desc">
    				<h3><?php echo $_main_category->getName(); ?></h3>
    				<p>The one thing about a Web site, it always changes! Joomla! makes it easy to add Articles, content,...</p>
    			</div>
    		</li>
    <?php
    	endforeach
    ?>
    I want to display product images only but it is giving me error like -
    Fatal error: Call to a member function getItems() on a non-object in C:\xampp\htdocs \xampp\Kaushal\ r4power\app\des ign\frontend\de fault\r4power\t emplate\catalog \navigation\sli der_horizontal_ nav.phtml on line 11.
    Last edited by Kaushal Elsner; Jun 24 '11, 09:29 AM. Reason: Error reporting not mentioned.
Working...