A general way to add observers to the events is:
An example:
app/etc/modules/MyCustom_Module.xml
<?xml version="1.0"?> <config> <global> <events> <urapidflow_product_import_after_fetch> <observers> <mycustommodule> <type>singleton</type> <class>MyCustom_Module_Model_Observer</class> <method>urapidflow_product_import_after_fetch</method> </mycustommodule> </observers> </urapidflow_product_import_after_fetch> </events> </global> </config>
app/code/local/MyCustom/Module/Model/Observer.php
<?php class MyCustom_Module_Model_Observer { public function urapidflow_product_import_after_fetch($observer) { $vars = $observer->getEvent()->getVars(); $oldData = $vars['old_data']; // custom logic here } }
There are 5 stages during product import process where a custom logic can be plugged in as an event observer:
urapidflow_product_import_after_fetch
- after fetching new and old dataurapidflow_product_import_after_validate
- after validating the new dataurapidflow_product_import_after_diff
- after finding the difference between new and old dataurapidflow_product_import_after_save
- after all changes has been savedurapidflow_product_import_after_rtidx
- after real-time reindex ran (if enabled in profile)The events are fired for each page of data (by default 100 rows), and each stage has more vars available than previous, and including all vars that were available before.
profile
- instance of current Unirgy_RapidFlow_Model_Profilenew_data
- rows fetched from CSV file (including any default values for missing columns, as specified in the profile)old_data
- product information for matching SKUs fetched from DBskus
- mapping of SKUs in the current page to product IDsattr_value_ids
- EAV attribute value IDs for fetched old dataThis example observer will change weight values of ā2kgā and ā470gā into correct decimal weight value.
app/code/local/MyCustom/Module/Model/Observer.php
<?php class MyCustom_Module_Model_Observer { public function urapidflow_product_import_after_fetch($observer) { $vars = $observer->getEvent()->getVars(); foreach ($vars['new_data'] as &$row) { if (strpos($row['weight'], 'kg')!==false) { $row['weight'] = intval($row['weight']); } elseif (strpos($row['weight'], 'g')!==false) { $row['weight'] = intval($row['weight'])/1000; } } unset($row); } }
valid
- which products passed or not validationinsert_entity
- new products to be createdchange_attr
- changed attributeschange_website
- changed product-website associationschange_stock
- changed inventory stock informationchange_category_product
- changed product-category associationsThere are 2 stages during product import process where a custom logic can be plugged in as an event observer:
urapidflow_catalog_product_export_before_format
- after fetching data from db and before formating for outputurapidflow_catalog_product_export_before_output
- after formating for output and right before writing to fileThe events are fired for each page of data (by default 100 rows), and each stage has more vars available than previous, and including all vars that were available before.
profile
products
fields
profile
products
fields
rows