Example:
$products = Mage::getModel('catalog/product')->getCollection(); //todo: add your filters here //custom options to be added $newCustomOptions = array( array( 'title' => 'Name', 'type' => 'field', 'is_require' => 1, 'sort_order' => 0, 'max_characters' => 255, 'values' => array() ), array( 'title' => 'Email', 'type' => 'field', 'is_require' => 1, 'sort_order' => 1, 'max_characters' => 255, 'values' => array() ), ); foreach($products as $product) { $currentCustomOptions = $product->getProductOptionsCollection(); //delete current custom options if($currentCustomOptions->getSize() != 0) { foreach ($currentCustomOptions as $option) { $option->delete(); } $product->setHasOptions(0); $product->save(); } Mage::getSingleton('catalog/product_option')->unsetOptions(); //add new custom options $product->setProductOptions($options); $product->setCanSaveCustomOptions(true); $product->save(); }