We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    There are two ways by which you can achieve this.

    1. Using observer concept.

    class Vendor_Namespace_Model_Observer
    {
    	public function customfunction($observer){
    		try
    		{
    			$item = $observer->getEvent()->getQuoteItem();
    			$item->setData(‘customvariable’, ‘somevaue’);
    			$item->save();
    			return $this;
    		}
    		catch (Exception $e)
    		{
    			echo $e->getMessage();
    		}
    	}
    }

    2. Another way is to create or custom add to cart function and place following code after add to cart.

    /* The following code will set custom value to sales flat quote item start */
    
    $quote = Mage::getSingleton(‘checkout/session’)->getQuote();
    $_item = $quote->getItemByProduct($_product);
    $_item->getProduct()->setIsSuperMode(true);
    $_item->setCustomvariable(“somevaue”)->save();
    
    /* The following code will set custom value to sales flat quote item end */

     

    field_5bfb909c5ccae

      Get a Free Quote