Set the value on the fly.
Is there a way to set the attributes value programatically? ie. when i load the product display node, how do i set my attribute values.
I tried to update this variable but the attribute select boxes did not update.
$colornid = 75;
$content['product:commerce_price']['#object']->field_my_field_attrib['und'][0]['value']=$colornid;
Thanks
Comments
Product display node is not product
Attributes are on the *product* entity. The product display node is not the product entity. You could programmatically *load* the product based on the value in the product reference field, and then you could set values and re-save. Sounds like trouble to me.
Maybe you can describe what you're trying to accomplish...
I need to preselect
I need to preselect attributes when a user visits a product display page.
My product display looks like this:
Select Boxes (#ajax) of:
Product: Tshirt (T-shirt, XL, blue) <<<< possible values: Pants (Pants, XL, blue) / Jacket (Jacket, XL, blue) / and so on...
Size: XL <<<< possible values: L / M / S
Color: blue <<<< possible values: red, white, green
I want Red as default so that it will be:
Product: Tshirt (T-shirt, XL, red)
Size: XL
Color: red
So you mean to say I should be setting the Product reference?
You need to select the
You need to select the *default product* in the product reference field, not an attribute.
So how do i set the product
So how do i set the product on the fly?
How do you set the product reference programatically
I am trying to accomplish something similar. I am checking a user field on a particular product display page and if its set to one thing I want one product to be the default. If it is set to something else or not set at all, I want a different product to be the default. How do you set the default product reference programatically in the form alter?
Or maybe not in the form alter?
Or maybe not in the form alter?