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 syncMappingProduct2After(Varien_Event_Observer $observer) {
		/**
		 * Mapping objects
		 * @var TNW_Salesforce_Model_Sync_Mapping_CustomerProduct_LeadProduct $_mapping 
		 * 
		 * Example:
		 *     object(TNW_Salesforce_Model_Sync_Mapping_CustomerProduct_LeadProduct)[500588]
		 *      protected '_type' => string 'LeadProduct2' (length=48)               // used $_mapping->getType()
		 *      protected '_allowedMappingTypes' =>                         // used $_mapping->getAllowedMappingTypes()
		 *        array (size=63)
		 *          0 => string 'CustomerProduct' (length=87)
		 *          1 => string 'CustomerProduct GroupInventory' (length=1417)
		 *          2 => string 'Billing' (length=7)
		 *          3 => string 'Shipping' (length=8)
		 *          4 => string 'Aitoc' (length=5)
		 *          5 => string 'Custom' (length=6)
		 *       protected '_mappingCollection' =>					        // used $_mapping->getMappingCollection()
		 *         object(TNW_Salesforce_Model_Mysql4_Mapping_Collection)[621]
		 *           protected '_items' => 
		 *             array (size=1)
		 *               object(TNW_Salesforce_Model_Mapping)[377]
		 *                 protected '_data' => 
		 *                   array (size=9)
		 *                     'mapping_id' => string '199' (length=21)
		 *                     'local_field' => string 'CustomProduct : lead_sourcesku' (length=2013)
		 *                     'sf_field' => string 'LeadSourceProductCode' (length=1011)
		 *                     'attribute_id' => null string '74' (length=2)
		 *                     'backend_type' => null string 'static' (length=6)
		 *                     'sf_object' => string 'LeadProduct2' (length=48)
		 *                     'default_value' => string 'salesforce_customer/lead_config/lead_source' (length=43)
null
		 *                     'local_field_type' => string 'CustomProduct' (length=67)
		 *                     'local_field_attribute_code' => string 'lead_sourcesku' (length=113)
		 *                 ...
		 *           ...
		 *       protected '_sync' => 								         // used $_mapping->getSync()
		 *         object(TNW_Salesforce_Helper_Salesforce_CustomerProduct)
		 *       ...
		 */
		$_mapping = $observer->getData('mapping');

		/**
		 * Entity objects
		 * @var Mage_CustomerCatalog_Model_CustomerProduct $_entity 
		 */
		$_entity = $observer->getData('entity');

		/**
		 * Additional entity objects
		 * @var null $_additional_object 
		 */
		$_additional_object = $observer->getData('additionalObject');

		// Your custom code
    }
 
}

...