title: How to modify custom attribute of custom attribute set while add to cart?
body: <p>I want to change my custom attribute(voucher_value) value of custom attribute set(Voucher) while add to cart. I have tried in observer event checkout_cart_product_add_after. I could manage to change price but could not change value of custom attribute voucher_value.</p>
  
  <p>Here is my function</p>
  
  <pre><code>    public function change_price($observer) {
          // Get the quote item
          $item = $observer-&gt;getQuoteItem();
          // Ensure we have the parent item, if it has one
          $item = ($item-&gt;getParentItem() ? $item-&gt;getParentItem() : $item );
          Mage::log("Item Details: ".print_r($item, true), null, 'item_before1.log');
          // Load the custom price
          $price = Mage::app()-&gt;getRequest()-&gt;getPost('custom_voucher_price');
              if(!empty($price)){
                      $product = Mage::getModel('catalog/product')-&gt;load($item-&gt;getProductId());
                      $product-&gt;addAttributeUpdate('voucher_value', 39 , 1);
                      //$product-&gt;addCustomOption('voucher_value_value', 259 , $product);
                      $product-&gt;save();
                      $voucher_discount = $product-&gt;getAttributeText('voucher_discount');
                      $voucher_value = $product-&gt;getAttributeText('voucher_value');
                      Mage::log("voucher_value: ".print_r($voucher_value, true), null, 'voucher_value.log');
                      $voucher_discount_amount = 0;
                      if($voucher_discount!=null &amp;&amp; (!empty($voucher_discount))){
                      $voucher_discount = floatval($voucher_discount);
                      $voucher_discount_amount = $price * $voucher_discount/100;
                      }
                      else{
                      $voucher_discount = 0;
                      }
                      $custom_price = $price - $voucher_discount_amount;
  
                      $item-&gt;setCustomPrice($custom_price);
  
                      $item-&gt;setOriginalCustomPrice($custom_price);
                      $info = $item-&gt;getOptions();
  
                  $option = Mage::getModel('sales/quote_item_option')
                      -&gt;setProductId($product-&gt;getId())
                      -&gt;setCode('voucher_value')
                      -&gt;setProduct($product) // needed for EE only ?
                      -&gt;setValue(39);
                  $item-&gt;addOption($option); 
                  $product = $observer-&gt;getProduct();
  
                  $item-&gt;setCustomAttribute($product-&gt;getCustomAttribute());
  
                  //  $item-&gt;setOptions($option);                
                  //  $item-&gt;setData('voucher_value_value', $price ); */
                  } 
      $item-&gt;save(); 
      // Enable super mode on the product.
      $item-&gt;getProduct()-&gt;setIsSuperMode(true);
  }
  </code></pre>
  
  <p>Please Help How do I change value of Custom attribute of custom attribute set.</p>