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 – zed Blackbeard Mar 20 '18 at 14:35
  • let us know in which format you are getting you $dimension value. Please add the array – Abhishek Panchal Mar 20 '18 at 14:55
  • format of dimension <Dimensions> 2&L x 3&W </Dimensions> – Devidas Mar 20 '18 at 15:03
  • are you trying to save to product or trying to assign size attribute options? – sandip Mar 21 '18 at 0:44
  • save to product – Devidas Mar 21 '18 at 6:33

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, privacy policy and cookie policy

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