Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

An event is triggered before sync order.

TNW_Salesforce_Block_Sales_Order_Status_New_Form
Mage::dispatchEvent('tnw_salesforce_sync_mapping_orderitem_before', array('mapping' => $_mapping, 'entity' => $_entity, 'additionalObject' => $_additional_object));

 

How to use this event:

Several steps are involved into utilizing this event:

  1. config.xml
    1. a listener should be added for this event
    2. a listener should point to a Magento Observer module and a method in that observer
  2. Magento Observer
    1. holds a method where you can add your custom logic
Example Config
<?xml version="1.0"?>
<config>
    <global>
        <events>
            <tnw_salesforce_sync_mapping_orderitem_before>
                <observers>
                    <salesforce_sync_mapping_orderitem_before_observer>
                        <class>tnw_salesforce/observer</class>
                        <method>syncMappingOrderitemBefore</method>
                    </salesforce_sync_mapping_orderitem_before_observer>
                </observers>
            </tnw_salesforce_sync_mapping_orderitem_before>
        </events>
    </global>
</config>
Example Observer
<?php

/**
 * Class TNW_Salesforce_Model_Observer
 */
class TNW_Salesforce_Model_Observer
{
 
    public function syncMappingOrderitemBefore(Varien_Event_Observer $observer) {
        /**
         * Mapping objects
         * @var TNW_Salesforce_Model_Sync_Mapping_Order_Order_Item $_mapping 
         * 
         * Example:
         *     object(TNW_Salesforce_Model_Sync_Mapping_Order_Order)[558]
         *       protected '_type' => string 'OrderItem' (length=9)	// used $_mapping->getType()
         *       protected '_allowedMappingTypes' => 				// used $_mapping->getAllowedMappingTypes()
         *         array (size=4)
         *           0 => string 'Cart' (length=4)
         *           1 => string 'Product Inventory' (length=17)
         *           2 => string 'Product' (length=7)
         *           3 => string 'Custom' (length=6)
         *       protected '_mappingCollection' => null              // used $_mapping->getMappingCollection()
         *       protected '_sync' =>                                // used $_mapping->getSync()
         *         object(TNW_Salesforce_Helper_Salesforce_Order)
         *       ...
         */
        $_mapping = $observer->getData('mapping');
 
        /**
         * Entity objects
         * @var Mage_Sales_Model_Order_Item $_entity 
         */
        $_entity = $observer->getData('entity');
 
        /**
         * Additional entity objects
         * @var Mage_Catalog_Model_Product $_additional_object 
         */
        $_additional_object = $observer->getData('additionalObject');

		// Your custom code
    }
 
}

 

Filter by label

There are no items with the selected labels at this time.

  • No labels