Custom options are the options that can be added to any product, which gives an option for the user of the site to select what type of product they actually want. Here is a scenario where custom option can be helpful. If you have a product say ball and your stores sells plastic,rubber,glass balls. So you need to give the user to select what type of ball they actually want. Yes, you can do this by using configurable product as well, but why create an attribute for one product only! In this case custom option might be very helpful.
Here’s the code to get the all the custom options of a product. Please see that you need to specify the id of the product for which you are retriving custom option for. I’ve echoed some text as well to give you an idea what exactly you are getting in each loop.
$product = Mage::getModel("catalog/product")->load(167);
$i = 1;
echo "<pre>";
foreach ($product->getOptions() as $o) {
echo "<strong>Custom Option:" . $i . "</strong><br/>";
echo "Custom Option TYPE: " . $o->getType() . "<br/>";
echo "Custom Option TITLE: " . $o->getTitle() . "<br/>";
echo "Custom Option Values: <br/>";
// Getting Values if it has option values, case of select,dropdown,radio,multiselect
$values = $o->getValues();
foreach ($values as $v) {
print_r($v->getData());
}
$i++;
echo "----------------------------------<br/>";
}
Happy coding in Magento!
Could you help me in telling that how can i display the custom option value of the particular product to admin side under Sales>order .
I have add the column but how to display its value under it ,i have edited
Grid.php file . please help me out
Hi Corp,
Are you creating a custom type of custom option? Because Magento’s Core types of Custom option will automatically be seen in sales->order.
If you are creating a new type of custom option then, I guess there is a problem in the Models somewhere..
I’m thankful to you for this neat and clean code.
Thank you very helpful!
Thank you so much, it helped me a lot,
Many thanks
Hi, thank you for this very useful post. I am a bit struggling to show just the price chosen by customer, from a dropbox option in cart.
What should I do in order to show value ‘price’ chosen by customer in cart ? If you have any recommandation I would be very thankful… Thanks you.
Thanx a lots its help me lots..!!!!!!!!!!!!
Thanx for share..its help me lots..!!!!!!
Thank you SO much for this! I spent WAY too many hours trying to find a solution. lol