How to get a collection of all configurable products and simple products ( not belonging to configurable product) in Magento custom module?
I have a custom code for getting all simple product which does belong to configurable product:
$collection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('type_id', array('eq' => 'simple'))
->addAttributeToSelect('*'); //or just the attributes you need
$collection->getSelect()->joinLeft(array('link_table' => 'catalog_product_super_link'),
'link_table.product_id = e.entity_id',
array('product_id')
);
$collection->getSelect()->where('link_table.product_id IS NULL');
And also have code for getting all configurable products:
$result = array();
$collectionConfigurable = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('type_id', array('eq' => 'configurable'))->addAttributeToSelect('*');
foreach($collectionConfigurable as $configurProduct)
{
$Title=$configurProduct->getName();
$id=$configurProduct->getId();
$result[] = array('value'=>$id,'label'=>$Title);
}
return $result;
I want to get a collection of above both.
How to do that?
Thanks in advance.