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

  • Home
  • SEARCH
  • 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 4533996
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:13:32+00:00 2026-05-21T14:13:32+00:00

I am trying to create an event dispatcher in Magento (which should be called

  • 0

I am trying to create an event dispatcher in Magento (which should be called after a product gets added to cart).

What I’ve done so far:

I Googled this and found this link. I followed the instructions specified in this link. I configured the config.xml file and created a Observer.php filder under mymodule/model folder. But, I can’t see any result from this.

(The code for config.xml and Observer.php file that i used in my example can be found under http://goo.gl/O7dBy, my custom module name is Crossdata and package name is MyModule – am i doing it wrong?)

Any other link with simple helloworld event dispatcher example would be helpful.

Thanks,
Balan

  • 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-21T14:13:33+00:00Added an answer on May 21, 2026 at 2:13 pm

    Looking at your code downloaded from http://goo.gl/O7dBy you define:

    <events>
        <add_to_cart_after>
            <observers>
                <add_to_cart_after>
                    <class>dispatcher/observer</class>
                    <method>hookToAddToCartAfter</method>
                </add_to_cart_after>
            </observers>
        </add_to_cart_after>
    </events>
    

    and define the model alias of dispatcher as:

    <models>
        <dispatcher>
            <class>MyPackage_Crossdata_Dispatcher_Model</class>
        </dispatcher>
    </models>
    

    The resulting class name would be MyPackage_Crossdata_Model_Dispatcher_Model_Observer, but your observer class is named MyPackage_Crossdata_Dispatcher_Model_Observer, missing the Model in between Crossdata and Dispatcher.

    I’d recommend to drop the whole dispatcher models definition above and only use the other model alias crossdata which you’ve already defined in config.xml:

    <crossdata>
        <class>MyPackage_Crossdata_Model</class>
        <resourceModel>crossdata_mysql4</resourceModel>
    </crossdata>   
    

    Then change the event definition to:

    <add_to_cart_after>
        <class>crossdata/observer</class>
        <method>hookToAddToCartAfter</method>
    </add_to_cart_after>
    

    Create a file /app/code/local/MyPackage/Crossdata/Model/Observer.php and define your observer class in it:

    class MyPackage_Crossdata_Model_Observer
    {
        public function hookToAddToCartAfter($observer)
        {
            // your observer code
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to create a generic event. Basically it should look like this:
I am trying to create a custom event which listens and responses to the
I am trying to create new Event objects to be persisted in the database
I'm trying to create an event through the Facebook Graph API and I keep
Im trying to create an ajax (post) event that will populate a table in
I have a database with event names and dates. I am trying to create
I'm trying to catch a double-click event in a TreeView's empty area to create
I am trying to create an event using Facebooks api. (From a django app)
I'm trying to create an event through the API and it is mostly working,
I'm trying to create an app which scans ports of given IP address individually

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.