How can I programmatically create products via REST? I have a module of rest service api, that is used to receive users upload products. Here is my code...

function commerce_services_product_create($data, $flatten_fields) {
    $status =1;
    $commerce_price = array();

    $sku = $data['sku'];
    $title = $data['title'];
    $type = $data['type'];
    $commerce_price = $data['commerce_price'];
    $price = $commerce_price['amount'];

    $cp = commerce_product_new('product');
    $cp-&gt;uid = 1;
    $cp-&gt;sku = $sku;
    $cp-&gt;title = $title;
    $cp-&gt;language = LANGUAGE_NONE;  

    $cp-&gt;commerce_price = array(
        LANGUAGE_NONE =&gt; array( 
            0 =&gt; array(
                'amount' =&gt; $price ,
                'currency_code' =&gt; 'MMK',
     )));

    // for store 
    $cp -&gt; cmp_store = array(LANGUAGE_NONE =&gt; $data["cmp_store"]);
    // for category
    $cp-&gt;field_category[LANGUAGE_NONE][0]['value'] = 137;

    try{
        commerce_product_save($cp);
        $result = "success!";
    }catch(Exception $ex){
        $result = "not success!, error -&gt; ". $ex;
    }
}


When I pass the following json string to the function, this function create a product but not include cmp_store, mean cmp_store is null.

{
  "sku": "saa_prduct120",
  "title": "saa_prduct",
  "type": "product",
  "commerce_price": {
    "amount": "150000",
    "currency_code": "USD"
  },
 "cmp_store": 2
}


And when I check store drop down button with themer info module, it shows #name as like this, "field_product[und][form][cmp_store][und]".

Above my code I use this code for adding store, mean when users upload their product, they have to choose store. User choose store is passed by json.

 // for adding store
 $cp -&gt; cmp_store = array(LANGUAGE_NONE =&gt; $data["cmp_store"]);


And I also try like this,

$new_product -&gt;field_data_cmp_store[LANGUAGE_NONE]['cmp_store']['und'] = $data["cmp_store"];
$new_product -&gt; field_product[cmp_store][und] = $data["cmp_store"];
$new_product -&gt; cmp_store = $data["cmp_store"];
$form_state['values']['cmp_store']['und'] =   $data["cmp_store"];


not ok yet!
This might need to work around as below

['field_store']['und']['#options'] = Store_array