Need Websites?

We, QuickBizTech have 8 Years of Exp in Web development in PHP and hosting. Skills: Photoshop, Designing, Core PHP, MySql, Joomla, Wordpress, Drupal, Magento, phpBB, Opencart, Smarty, Google API, JQuery, Charts, oAuth, SEO, Payment Gateways.


Please contact us for any kind of websites to be developed, upgraded, migrated. Reach our team for your dream website @QuickBizTech

Saturday, September 21, 2013

Get products by category id in Magento

It is always recommended to fetch any data from mangeto using its api/helper.

Here the code to get list of products by passing category id with the help of magento helper.

if it is current category,

$category = Mage::registry('current_category');

If not,

$categoryid = 12;
$category = new Mage_Catalog_Model_Category();
$category->load($categoryid);

Then,

$items = $category->getProductCollection();
$items->addAttributeToSelect('*');

$p_ids = array();

foreach($items as $item)
{
  $p_ids[] = $item->getID();
}

No comments:

Post a Comment