It's not possible to do this without making changes to Magento.
Now suppose you wanted to predefine the selected options of a select box in the url:
First you need to overwrite the block *Mage_Catalog_Block_Product_View_Options_Type_Select*. (I assume that you have created your own module already - I you haven't and need help with that let me know)
To do this you need to add this entry to your config.xml:
<config>
<global>
<blocks>
<catalog>
<rewrite>
<product_view_options_type_select>YourCompany_YourModuleName_Product_View_Options_Type_Select</product_view_options_type_select>
</rewrite>
</catalog>
</blocks>
</global>
</config>
Next add the class *YourCompany_YourModuleName_Product_View_Options_Type_Select* which needs to extend *Mage_Catalog_Block_Product_View_Options_Type_Select*.
In this class you must now overwrite the function getValuesHtml(). To start off you should copy it from the class you're extending.
In this function you should find this foreach
:
foreach ($_option->getValues() as $_value) {
$priceStr = $this->_formatPrice(array(
'is_percent' => ($_value->getPriceType() == 'percent') ? true : false,
'pricing_value' => $_value->getPrice(true)
), false);
$select->addOption(
$_value->getOptionTypeId(),
$_value->getTitle() . ' ' . $priceStr . ''
);
}
After this you add:
$standardValue = $this->getRequest()->getParam($_option->getid());
//Mage::log("Option Name: "$_option->getid());
$select->setValue($standardValue);
This should do it. Unfortunately I can't test this right now. So let me know if you run into troubles.
I'm not sure if the $_option->getid()
is the right name for your parameter. But you could try to find that out if you comment in the one line I commented out for you in the code listing from above.
In your Magento installation open the file var/log/system.log where the name of your url parameters should now appear.
Now that you know the how to name the url parameters you can do exactly what you wanted: *url/to/product?option_id=value_id*
PS: If you ask yourself why we create a new class instead of changing it directly in the Magento core: We do this to prevent problems when updating to a new version of Magento.
I hope I could help.