1

i have to get the products which do not contain any custom option, but not using has_options flag. The aim of doing this if the products do not contain any option, i have to set has_options to 0 progmatically(may be through magmi).

Is there any filter statement can select the products which do not have have custom options?

hkguile
  • 2,221
  • 5
  • 45
  • 85

1 Answers1

1

It not proper way to get non custom option products using has_options field.has_option is set to 1 when it bundle.

Good idea to join the table catalog_product_option to collection and and using join query check product have custom option or not

Here Step1: Get Collection of product which have option and then group them by product id

$Option=Mage::getResourceModel('catalog/product_option_collection')->addFieldToSelect('product_id');
$Option->getSelect()->group('main_table.product_id');

Step2: filter product collection by excluding those products getting from step1

   $entityIds = new Zend_Db_Expr($Option->getSelect()->__toString());
    $Collection=Mage::getResourceModel('catalog/product_collection');
    echo $Collection->getSelect()->where('e.entity_id not in(?)', $entityIds);
Amit Bera
  • 77,456
  • 20
  • 123
  • 237