I am trying to work through a problem, but am not having any success. I need to send down some additional information with the Magento API order info request. Unfortunately, Magento doesn't seem to have any events tied to this, so I overwrote that class and to dispatch an event. That is all well and fine, as I modify the $result
array, with the new information. However the part that is not fine is that the array that was modified never shows back up in the original dispatching code.
Here is the dispatch:
class Company_Module_Model_Order_Api extends Mage_Sales_Model_Order_Api {
public function info($orderIncrementId) {
$result = parent::info($orderIncrementId);
$order = $this->_initOrder($orderIncrementId);
Mage::dispatchEvent("company_api_order_info_add",
array('result' => &$result, 'order' => &$order));
// - I've tried with and without the ampersand
Mage::log($result['affiliate_text']); // Debugging
return $result;
}
}
Here is the watcher code:
class Company_Other_Model_Api
{
public function hookToSetAffiliate ($observer) {
$result = $observer->getResult();
$order = $observer->getOrder();
if ($order->getAffiliateCode()) {
$affiliate = Mage::getModel('affiliates/info')
->load($order->getAffiliateCode());
if (is_object($affiliate))
$result['affiliate_text'] = $affiliate->getCode();
}
Mage::log($result['affiliate_text']); // Shows up here
return $observer;
}
}
}
Do you have any ideas why $result
is not coming in properly? In the hook, it show up properly, however, 'affiliate_text'
is not visible when the next line of the dispatching method occurs.
Thanks,
JMax