Home » Magento

Magento: Get Product Collection by Type

20 April 2010 8,616 views Popularity: 18% Share/Bookmark

email

Here, I will be showing how you can get product collection from product type i.e. simple, configurable, bundle, grouped, and virtual.

Here is the code:-

$collectionSimple = Mage::getResourceModel('catalog/product_collection')
				->addAttributeToFilter('type_id', array('eq' => 'simple'));

$collectionConfigurable = Mage::getResourceModel('catalog/product_collection')
				->addAttributeToFilter('type_id', array('eq' => 'configurable'));

$collectionBundle = Mage::getResourceModel('catalog/product_collection')
				->addAttributeToFilter('type_id', array('eq' => 'bundle'));

$collectionGrouped = Mage::getResourceModel('catalog/product_collection')
				->addAttributeToFilter('type_id', array('eq' => 'grouped'));

$collectionVirtual = Mage::getResourceModel('catalog/product_collection')
				->addAttributeToFilter('type_id', array('eq' => 'virtual'));

Cheers,

Related posts:

  1. Magento: How to filter product collection using 2 or more category filters?
  2. Magento: Sort latest product by ‘created date’ and ‘new from date’
  3. Magento: Get sub categories and product count
  4. Magento: How to get most viewed products?
  5. Magento: Get parent id of simple product associated to configurable product
  6. Magento: How to get all associated children product of a configurable product?
  7. Magento: Load store specific product
  8. Magento: Get category name and url from product
  9. Magento: Product Edit Warning: Invalid argument supplied for foreach()
  10. Magento: How to get product stock quantity & other stock information?
  • VicHaunter

    Hello, very interesting, but i want to know how to filter for example simple and configurable with the same filter, or any other combination of 2 or 3 different types in the same collection.
    Is this possible? thankyou

  • Lalit Patel

    Thank you for this post. Very help full

  • Ela

    Hi ,

    I want to get the all the sku’s of the Configurable product inner products. How can i alter your method to get the sku’s of the configurable products

    $collectionconfigurable = Mage::getResourceModel(‘catalog/product_collection’)
    ->addAttributeToFilter(‘type_id’, array(‘eq’ => ‘configurable’));
    Zend_Debug::dump($collectionconfigurable);

  • Jerome Dennis D

    Hi brother i don’t know how to thank you.

    You have saved me a lot of time through your very precise articles which hit straight at the target in my magento development  and i would also like to donate you to help this blog as soon as i can :-)

    Keep rocking with your articles. Its not an exaggeration if i would say this blog is a Magento Cook Book.

    Thanks and Regards,
    Jerome Dennis D
    http://haijerome.wordpress.com