Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
titleExample Observer
<?php

/**
 * Class TNW_Salesforce_Model_Observer
 */
class TNW_Salesforce_Model_Observer
{
 
    public function orderSendAfter(Varien_Event_Observer $observer) {
		/** 
		 * Array of Salesforce objects
		 * @var array $_data 
		 * 
		 * Example:
		 * array (size=1)
		 *   100000083 => // 100000083 - Magento Order Number
		 *     object(stdClass)[583]
		 *       public 'BillToContactId' => string '0032400000M41daAAB' (length=18)
		 *       public 'ShipToContactId' => string '0032400000M41daAAB' (length=18)
		 *       public 'tnw_mage_basic__BillingCustomer__c' => string '0032400000M41daAAB' (length=18)
		 *       public 'Status' => string 'Draft' (length=5)
		 *       public 'tnw_mage_basic__Magento_Website__c' => string 'a002400000CSEGD' (length=15)
		 *       public 'tnw_mage_basic__Magento_ID__c' => string '100000083' (length=9)
		 *       public 'Pricebook2Id' => string '01s24000004r4t6AAA' (length=18)
		 *       public 'EffectiveDate' => string '2013-04-22T14:48:29+00:00' (length=25)
		 *       public 'AccountId' => string '0012400000Q0YdkAAF' (length=18)
		 *       public 'BillingStreet' => string 'Canal Street' (length=12)
		 *       public 'BillingCity' => string 'Michigan' (length=8)
		 *       public 'BillingState' => string 'Michigan' (length=8)
		 *       public 'BillingPostalCode' => string '49036' (length=5)
		 *       public 'BillingCountry' => string 'US' (length=2)
		 *       public 'ShippingStreet' => string 'Canal Street' (length=12)
		 *       public 'ShippingCity' => string 'Michigan' (length=8)
		 *       public 'ShippingState' => string 'Michigan' (length=8)
		 *       public 'ShippingPostalCode' => string '49036' (length=5)
		 *       public 'ShippingCountry' => string 'US' (length=2)
		 *       public 'Description' => string 'Items ordered:
		 * =======================================
		 * SKU, Qty, Name, Price, Tax, Subtotal, Net Total
		 * =======================================
		 * abl003, 1.00, Broad St. Flapover Briefcase, USD400.00, USD29.00, USD429.00, USD410.82
		 * abl004, 1.00, Houston Travel Wallet, USD150.00, USD10.88, USD160.88, USD154.06
		 * =======================================
		 * Sub Total: USD550.00
		 * Tax: USD39.88
		 * Shipping (United Parcel Service - Ground): USD15.22
		 * Discount Amount: USD-25.00
		 * Total: USD580.10
		 * ' (length=479)
		 *       public 'Type' => string 'Magento' (length=7)
		 *       public 'Name' => string 'Magento Order #100000083' (length=24)
		 */
		$_data = $observer->getData('data');

		/**
		 * Array of Results
		 * @var array $_result 
		 * 
		 * Example:
		 * array (size=1)
		 *   0 => 
		 *     object(stdClass)[534]
		 *       public 'created' => boolean false
		 *       public 'id' => string '80124000001479HAAQ' (length=18)
		 *       public 'success' => boolean true
		 */
		$_result = $observer->getData('result');

		/** 
		 * @var string $_field 
		 */
		$_field = $observer->getData('field');

		// Your custom code
    }
 
}

...