1

As the title says, I'm trying to set/modify the value of a drop down type attribute through the SOAP v2 API. Below is the latest bit of code that I'm working with:

$update_data = array (
    'additional_attributes' => array (
        'multi_data' => array (
            array ('key' => 'ship_separately', 'value' => array ('0' => '1'))
        ),
        'single_data' => array (
            array ('key' => 'ship_width', 'value' => '14'),
            array ('key' => 'ship_length', 'value' => '24'),
            array ('key' => 'ship_height', 'value' => '12'),
            //array ('key' => 'ship_separately', 'value' => 'Yes')
        )
    )
);

$update = $proxy->catalogProductUpdate($sessionId, 'MySKU', $update_data, NULL, 'sku');

The 'single_data' (just simple name/value pairs) attributes update fine. As you can see, I also tried to update the 'ship_separetely' using the 'single_data' array...to no avail. Google and StackExchange put me on the path of the 'multi_data' array, but finding documentation on it is virtually impossible. I think I have the syntax correct because the API isn't throwing an exception and it is updating the 'single_data' attributes, but won't update the drop down value. It is a simple yes/no drop down, so I've tried setting the value to both 'Yes' and '1', but it doesn't change. Any help is greatly appreciated.

  • It might seem stupid but have you tried setting it to 1 or true without the quotes? – Mayers Feb 1 '16 at 16:43
  • Not stupid at all; I'm hoping it is something simple like that. Just gave it a shot, but no luck. No error, but no update either. Thanks! – John Feb 1 '16 at 16:48
  • In your code, you have misspelled separately, that probably doesn't help – Mayers Feb 1 '16 at 16:50
  • Yeah, I caught that while I was making this post and thought that was it. Changed it to the proper spelling and tried, but that didn't work either. I just forgot to change it in the post. Changed now. – John Feb 1 '16 at 16:57
  • I have just tested myself and '1' works perfect for me. Are you sure you got the name right? If it's been newly created, you will need to Flush Magento cache or else it won't know the field exists. – Mayers Feb 2 '16 at 9:31
1

Just in case someone else is having a bad day like me, the solution was to set the value to '1', but not in a 'multi_data' array...

$update_data = array (
    'additional_attributes' => array (
        'single_data' => array (
            array ('key' => 'ship_width', 'value' => '14'),
            array ('key' => 'ship_length', 'value' => '24'),
            array ('key' => 'ship_height', 'value' => '12'),
            array ('key' => 'ship_separately', 'value' => '1')
        )
    )
);

$update = $proxy->catalogProductUpdate($sessionId, 'MySKU', $update_data, NULL, 'sku');

Many thanks to Mayers

  • Odd, because in Mage_Catalog_Model_Product_Api_V2 I can't see any different between the two. But glad it worked for you :) – Mayers Feb 4 '16 at 16:43

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.