1

I'm creating new customers in C# via the SOAP v2 API because why not.

I've set the website_id and store_id attributes of my customerCustomerEntity object to 1 which is the default main website and default main store respectively. The customerCustomerCreate() request then goes off without a hitch.

Unfortunately, when I check out the created customer in my Magento admin panel, I see that it's incorrectly associated with the admin site and not my default main site.

I'm using Magento 1.8.1.

If anyone have any ideas about why this is happening and how to fix it, I'd be eternally grateful.

Thanks. :)

2

Okay, for some absurd reason, when using the API in this setting, you have to set the website_idSpecified and store_idSpecified members of customerCustomerEntity to true.

A lot of optional attributes of all the API entity classes have a corresponding attribute_nameSpecified boolean that you have to remember to set if you are passing in those optional attributes, otherwise they just aren't recognised.

Sorted!

1
  • 1
    Hi, Just wanted to add that there is a good reason for the xSpecified fields. As C# is a strongly typed language, the int field can only contain a valid int. (PHP does not force this constraint). Without the xSpecified field the Soap Client would have no way to separate out the case where the value should not be sent and the value is 0 or negative. Now in the magento context of website_id you can make an assumption about the range of values allowed and say that -1 is invalid so don't send, but this is not within the ken of the Soap Client. I hope this helps you understand.
    – SH-
    Nov 25 '15 at 16:53

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.