how to resolve undefined property error This is my code: 

function my_module_node_presave($node){
  if ($node-&gt;type == 'add_stock') {
    $stock_value = $node-&gt;field_stock_value['und'][0]['value'];
    drupal_set_message('stock_value :'.$stock_value);

    $sku = $node-&gt;field_sku['und'][0]['value'];
    drupal_set_message('sku :'. $sku);

    $key = $node-&gt;field_reference['und'][0]['nid'];
    drupal_set_message('key :'. $key);

    $key1 = node_load($key);
    //$pnode =  $key1-&gt;field_product_stock['und'][0]['value'];
    //drupal_set_message('key1 :'.$key1);
    //if (module_exists('uc_stock') &amp;&amp; function_exists('uc_stock_adjust')) {

      uc_stock_set($node-&gt;$sku, $stock_value);
      uc_stock_adjust($node-&gt;$sku, $stock_value);

    //}
  }
}


The error I get is the following one: 


  Notice: Undefined property: stdClass::$tshirt-11 in my_module_node_presave() (line 40 of
  D:\xampp\htdocs\photo\photogallary\sites\all\modules\my_module\my_module.module).  
  
  Notice: Undefined property: stdClass::$tshirt-11 in my_module_node_presave() (line 41 of
  D:\xampp\htdocs\photo\photogallary\sites\all\modules\my_module\my_module.module).
When you write $node-&gt;$sku, PHP takes the value of $sku and uses it as name of a property.
In your case, $sku contains 'tshirt-11', and $node-&gt;$sku is equivalent to $node-&gt;tshirt-11. Since $node-&gt;tshirt-11 is not defined, you get the error you see.

The code you should write is the following one.

  uc_stock_set($sku, $stock_value);
  uc_stock_adjust($sku, $stock_value);


As side note, the value of a field is accessed using field_get_items(). The code you use to set $sku should be rewritten as the following.

$items = field_get_items('node', $node, 'field_sku');
$sku = $items[0];