I don't know if recommending an extension counts as a valid answer (for a question with a bounty) but someone claims here that he wrote an extension that does exactly what you need. Extension can be downloaded from here. I haven't tested it but, as soon as I do, I will post and update. I only looked through the code and there is a lot of it. I lost interest after 2 files. I hope it works for you.
[EDIT]
I've got my interest back. I tested the extension on ce-1.7.0.2 and it (almost) works.
If you use it with developer mode on you will get some errors. Here is what you need to change to make it work.
in /app/code/local/Magebuzz/Customoption/controllers/Adminhtml/CustomoptionController.php
on line 28 there is this:
$model->setData('value['.$option_id.']',$value[0]['option_type_id']);
This shows an 'undefined index' warning. To avoid it, wrap it in an if
statement.
if (isset($value[0])){
$model->setData('value['.$option_id.']',$value[0]['option_type_id']);
}
In /app/code/local/Magebuzz/Customoption/Block/Adminhtml/Customoption/Edit/Tab/Form.php
on line 129 there is this:
foreach ($values as $value) {
$valuesArr[$value['option_type_id']]=$value['title'];
}
$values
may be null so change the code to this:
if (is_array($values)){
foreach ($values as $value) {
$valuesArr[$value['option_type_id']]=$value['title'];
}
}
Now it should work.
Now some review.
- PRO. Works perfectly for dropdown and radio custom options
- Neurtal. Kind of works for multiple select and checkbox custom options. You can select only one value for the available values.
- Inconvenient but I can overlook it. in order to set the default values you have to click on an other menu item in the backend and look for your product in the list.
- Con. It doesn't work for text, textarea, date, datetime, time, file custom options. But with a little work it can be changed to work correctly for all types (maybe except file).
Magento does not support this. The custom options prices are relative to the base price.
I think a better way of doing it, in order not to interfere with the magento pricing calculation system (that's kind of a monster) is to either set the prices for the custom options relative to the base price or set the base product price to 0.
Working with the same example you gave,
you either set the prices of your custom options to 20$
and 40$
.
Or, if the custom option is mandatory set the base price to 0 instead of 30 and leave the custom options prices as they are.
Best Answer
Go to
Mage/Catalog/Block/Product/View/Options/Type/Select.php::getValuesHtml()
Comment (in line no 59) the
addOption
part ofi.e.
/* -
>addOption('', $this->__('-- Please Select --'));
*/Hope this solves your issue.