0

I want to get all product which have custom option as radio type. How to load product having custom option radio type. ?

2 Answers 2

1

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);

Source

0
$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;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.