Question

In my magento sales_flat_quote table I've added a new column (using ALTER TABLE) called 'simple_test_token'.

Now, I am trying to get and set the value of that column for a selected quote object. I am trying this code, which doesn't seem to get or set the value.

//      Get the quote
        $quote = Mage::getModel('sales/quote')->load($quoteId);
//      set quote value
        $quote->setAttribute(1,'simple_test_token');
//      Retrieve quote value
        $tokenValue = $quote->getAttribute('simple_test_token');

EDIT:

Resolved the issue using camel case getters and setters. Note you must use loadByIdWithoutStore() instead of load() to retrieve the correct quote object.

//Set attribute
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
$quote->setSimpleTestToken(1);
$quote->save()

//Get attribute
$quote->getSimpleTestToken();
Was it helpful?

Solution

//      Get the quote
        $quote = Mage::getModel('sales/quote')->load($quoteId);
//      set quote value
        $quote->setSimpleTestToken(1);

        $quote->save()

// after save you can retrieve value

// Retrieve quote value

 $tokenValue = $quote->getAttribute('simple_test_token');

Let me know if you have any query

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top