I want to set one string value to sizes attribute in drop-down ?

           //get sage dimension value
           $dimension = $value->Dimensions;    

            //set value
            $inStock = 1;                            
                    'use_config_manage_stock' => 0,
                    'manage_stock' => 1,
                    'is_in_stock' => $inStock,
                    'qty' => $minqty

             //set dimension value to sizes dropdown attribute


Below attribute not set in drop-down.


Any idea, how can I set dimension value in sizes attribute?


enter image description here

Actual Output:-

enter image description here

  • Add more information Commented Mar 20, 2018 at 14:35
  • let us know in which format you are getting you $dimension value. Please add the array Commented Mar 20, 2018 at 14:55
  • format of dimension <Dimensions> 2&L x 3&W </Dimensions>
    – Devidas
    Commented Mar 20, 2018 at 15:03
  • are you trying to save to product or trying to assign size attribute options?
    – sandip
    Commented Mar 21, 2018 at 0:44
  • save to product
    – Devidas
    Commented Mar 21, 2018 at 6:33

1 Answer 1


I get the Size of attribute values and I have checked the post value match to the attribute list. If matched then set the value to the product

foreach ($result as $key=>$value) {
  if ($value['value'] == $dimension ) 
    $size_option_id = $value['option_id'];


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.