Today I'll discuss, how to delete duplicate custom options from product in magento.
First of all make a file on magento root directory and paste below code on that file and after that run this file.
This will delete duplicate custom options from product.
Here is the code:-
[php]
<?php
ini_set("memory_limit","1024M");
set_time_limit(0);
require 'app/Mage.php';
Mage::app();
$productobj = Mage::getModel('catalog/product');
$productsArr = $productobj->getCollection()
->addAttributeToSelect('*')->addAttributeToFilter('type_id','configurable')
->getdata();
foreach ($products as $product) {
$productobj->load($product['entity_id']);
$i= 0;
foreach ($productobj->getOptions() as $o) {
$optionType = $o->getType();
if ($optionType == 'drop_down') {
$values = $o->getValues();
$title = $o->getTitle();
$product[$i] = $title;
for($j=0;$j<$i;$j++)
{
if($product[$j]==$product[$i])
{
$o->delete();
echo "DUPLICATE OPTION :". $product[$i]."DELETED";
echo "<br/>";
}
}
}
$i++;
}
}
?>
[/php]