Magento: Get Product Collection by Type
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:
- Magento: How to filter product collection using 2 or more category filters?
- Magento: Sort latest product by ‘created date’ and ‘new from date’
- Magento: Get sub categories and product count
- Magento: How to get most viewed products?
- Magento: Get parent id of simple product associated to configurable product
- Magento: How to get all associated children product of a configurable product?
- Magento: Load store specific product
- Magento: Get category name and url from product
- Magento: Product Edit Warning: Invalid argument supplied for foreach()
- Magento: How to get product stock quantity & other stock information?
