Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6757879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:42:29+00:00 2026-05-26T13:42:29+00:00

I am trying to work through a problem, but am not having any success.

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:42:30+00:00Added an answer on May 26, 2026 at 1:42 pm

    I would suggest you take the same route that Magento does.

    // Wrap array in an object
    $result = new Varien_Object($result);
    
    // Dispatch - No need for & as $result and $order are both objects and passed by ref
    Mage::dispatchEvent("company_api_order_info_add", array('result'=>$result, 'order'=>$order));
    
    // Unwrap array from object
    $result = $result->getData();
    

    Varien_Object will still allow array access, so your listener code shouldn’t have to change at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to work through the problems on projecteuler.net but I keep running into
I'm trying to work through Project Euler and I'm hitting a barrier on problem
I'm trying to work through this guide to Rails routing , but I got
I,m trying to work through and test a Voice Recognition example based on the
Hey all, here is the issue I am currently trying to work through. We
I have been trying to work my way through Project Euler, and have noticed
I'm trying to work my way through Ron Jeffries's Extreme Programming Adventures in C#.
I'm trying to work my way through an Objective-C tutorial. In the book there
I am trying to serialize a ItemTransaction and protobuf-net (r282) is having a problem.
I am having a problem with my java code. I'm trying to make it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.