1

In my Magento 1.9, I have an extension fooman surcharge installed. and the extension added some extra fields into sales_flat_order

How can I programmatically retrieve the data from these fields?

for example in the screenshot, I want to get the data from the field fooman_surcharge_amount.

enter image description here

5

You can get values from order object as follows.

$surchargeAmount = $order->getData('fooman_surcharge_amount');

Where $order is previously loaded order object.

| improve this answer | |
  • 1
    Thanks Kishan for answering: $order->getFoomanSurchargeAmount() would work too. – Kristof at Fooman Jun 9 '17 at 9:31
  • @KristofatFooman Thanks for the comment, I can not find where is this getFoomanSurchargeAmount() function defined in your extension. How does it work for the getFoomanSurchargeAmount()? – Magento Learner Jun 14 '17 at 11:40
  • 1
    @xxx that is the standard magic getter from Magento. Essentially when you write $order->getFoomanSurchargeAmount() it translates this into $order->getData('fooman_surcharge_amount') – Kristof at Fooman Jun 15 '17 at 1:59
2

You can load order by entity id

$order = Mage::getModel('sales/order')->load(24999); //use an entity id here

Or by increment_id

$order = Mage::getModel('sales/order')->loadByIncrementId('10000001'); //use a real increment order id here

you can see all field value of order by

print_r($order->getData());
| improve this answer | |
1

You can get this array and dump it via:

print_r($order->getData());
// or
var_dump($order->getData());

You will get an output like this with print_r():

Array
(
    [entity_id] => 2
    [state] => new
    [status] => pending
// ...
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.