I want to get all product which have custom option as radio type. How to load product having custom option radio type. ?
2 Answers
Step1: Get Collection of product which have option as type radio and then group them by product id
$Option=Mage::getResourceModel('catalog/product_option_collection')
->addFieldToSelect('product_id')
->addFieldToFilter('type','radio');
$Option->getSelect()->group('main_table.product_id');
Step2: filter product collection by those products getting from step1
$entityIds = new Zend_Db_Expr($Option->getSelect()->__toString());
$Collection=Mage::getResourceModel('catalog/product_collection');
$Collection->getSelect()->where('e.entity_id in(?)', $entityIds);
$options = Mage::getModel('catalog/product_option')
->getCollection()
->addFieldToFilter('type', array('eq','radio'))
->distinct(true)
;
foreach ($options as $key => $option) {
if($option->getData('type') == 'radio'){
$productId = $option->getProductId();
echo $productId;
}
}