Send Gift Card Data from Magento to RetailOps

Magento allows for the sale of gift cards that customers may purchase to be sent to their family and friends. To send this gift card data back to RetailOps, you will need to make two modifications:

  1. Add an Observer to Module Configuration
  2. Implement the Observer Function

Add an Observer to the Module Configuration

You must add an observer on the "retailops_order_pull_record" event in your module configuration (e.g., <document_root>/magento/app/code/community/Acme/etc/config.xml) as follows:

<config>
...
  <global>
...
    <events>
...
      <retailops_order_pull_record>
        <observers>
          <acme_gift_card_observer>
            <class>acme/observer</class>
            <method>transferMyGiftCardValue</method>
          </acme_gift_card_observer>
        </observers>
      </retailops_order_pull_record>
...
    </events>
...
  </global>
...
</config>  

Implement the Observer Function

Next, you need to create and implement the observer function in the class referenced in your module configuration above (e.g. <document_root>/magento/app/code/community/Acme/Model/Observer.php). This function will be passed on an object that contains an event with an associated order record. This order record will contain the gift card value from the extension module, which must be transferred into the order record field that RetailOps expects: record['order_info']['gift_cards_amount']

Note that the location of the gift card value is subject to how the module being used was written. In this example, the value is in: record['order_info']['my_gift_card_amount'].

class Acme_Model_Observer
{
...
    /*
     * Transfer MyGiftCardPlugin amount to 'gift_cards_amount' for RetailOps Orders
    */	
    public function transferMyGiftCardValue(Varien_Event_Observer $observer) {
        $record = $observer->getEvent()->getRecord();
        $orderInfo = $record->getOrderInfo();
        $orderInfo['gift_cards_amount'] = $orderInfo['my_gift_card_amount'];
        $record->setOrderInfo($orderInfo);
    }
...
}
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk