473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $_main_categories = $this->getStoreCategories();
  3.  
  4.     foreach ($_main_categories as $_main_category):
  5. ?>
  6.         <li>
  7.             <div style="width:593px;">
  8.             <?php
  9.                 $_products = $_main_category->getProductCollection();
  10.                 $i=0;
  11.                 foreach ($_products->getItems() as $_product):
  12.                     if($i<3)
  13.                     {
  14.             ?>
  15.                         <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(80) ?>" />
  16.             <?php
  17.                     }
  18.                 $i++;
  19.                 endforeach
  20.             ?>
  21.             </div>
  22.  
  23.             <div class="lof-main-item-desc">
  24.                 <h3><?php echo $_main_category->getName(); ?></h3>
  25.                 <p>The one thing about a Web site, it always changes! Joomla! makes it easy to add Articles, content,...</p>
  26.             </div>
  27.         </li>
  28. <?php
  29.     endforeach
  30. ?>
  31.  
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\design\f rontend\default\r4power\template\catalog\navigatio n\slider_horizontal_nav.phtml on line 11.
Jun 24 '11 #1
0 1234

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Troy Lynch | last post by:
I'm working on writing a website which I need to have lists of products listed in categories and subcategories, and need to keep track of whats in the tree. Like how many products from the root all...
0
by: Ralph Guzman | last post by:
TASK: I have to generate a report with all categories, subcategories and products in database. PROBLEM: I want to write one query that will return: 1. category 2. subcategory: determined by...
0
by: Pierre de LESPINAY | last post by:
Hello Simplifying my problem: I have 3 tables. user_master ---------- int user_id char user_name
1
by: Mark | last post by:
My Category and Product tables look like: TblCategory CategoryID Category TblProduct ProductID CategoryID Product
4
by: Erik Thorsen | last post by:
I need help with a tricky questions which I belive have a simple solution? For those who know Nwind.mdb, the example database that comes with microsoft access, it has several different tables. One...
1
by: savvy | last post by:
I'm using MS SQL 2000. I developing a shopping cart where on the admin side when we are inserting or updating the products, there is a chance that a single product can fall into two categories...
13
by: hornedw | last post by:
I have been working on a ecommerce website for myself. What I needed some assistance on was when i was trying to display the categories/subcategories for the different products. I decided to use...
1
realayumi
by: realayumi | last post by:
ACCESS 2003 WIN XP Hi, i'm new in access, just a view days, this is my first post. Sorry for my bad English. I have 3 tables. tbl_product
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.