Search code examples
.netmagentosoapmagento-soap-api

Magento API .Net: Retrieve product option name-value from order


I need to know how to retrieve each product's custom options (name/value) in an order.

For example in my order I have 1x product of lets say "Coloured Crayon". This product has a custom option of "Colour" which the customer selects when adding the product to their basket.

When I process the customer's order I would like to be able to retrieve the option name and option value.

Note 1 Using Magento 1.7 community edition, developing in .Net using SOAP with Magento API v2.

I discovered that a salesOrderEntity Items property called product_options contains what looks like a JSON encoded list of product option VALUES ONLY. This list contains no attribute names but instead has what looks like ID's where I'd think to see option names.

salesOrderEntity theOrder = apiService.salesOrderInfo(sSessionId, "100000001");      
string sProductOptions = theOrder.items[0].product_options; // returns JSON like string syntax

Solution

  • After further investigation I've discovered that the response I am getting from the product_Options property is serialised php (wth?).

    It looks something like this (similar to JSON) if you neaten it up:

    a:3:{s:7:"colours";a:3:{i:0;s:4:"pink";i:1;s:6:"orange";i:2;s:3:"red";}s:6:"intkey";i:1;s:6:"colour";s:4:"blue";}
    

    I've looked around and found a C# php serialiser/deserialiser and have successfully deserialised the response from the API.

    Here is the link to the C# deserialiser.