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 6646633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:26:24+00:00 2026-05-26T00:26:24+00:00

I’m trying to get a simple event observer working but I don’t know if

  • 0

I’m trying to get a simple event observer working but I don’t know if it is even possible under these circumstances. Ultimately, I’d like to fire an event when Shipworks pushes order updates. I think because Shipworks is done entirely in their shipworks3.php script and doesn’t call Mage::run() to initialize the full store (it uses Mage::app(''), the observers aren’t attached to the events…at least that’s my going theory at this point. However, I can’t seem to get it to work.

Below is some sample code I threw together to test this out. Please let me know if you have any thoughts on this

EXAMPLE

First, I created a simple module with an observer and a frontend controller for testing purposes:

config.xml

<config>
    <modules>
        <VPS_Test>
            <version>0.1.0</version>
        </VPS_Test>
    </modules>
    <global>
        <models>
            <vps_test>
                <class>VPS_Test_Model</class>
            </vps_test>
        </models>
    </global>
    <events>
        <test_event_one>
            <observers>
                <test_event_one>
                    <type>singleton</type>
                    <class>VPS_Test_Model_Observer</class>
                    <method>foo_test_global</method>
                </test_event_one>
            </observers>
        </test_event_one>
    </events>
    <frontend>
        <events>
            <test_event_one>
                <observers>
                    <test_event_one>
                        <type>singleton</type>
                        <class>VPS_Test_Model_Observer</class>
                        <method>foo_test_front</method>
                    </test_event_one>
                </observers>
            </test_event_one>
        </events>
        <routers>
            <vps_test>
                <use>standard</use>
                <args>
                    <module>VPS_Test</module>
                    <frontName>vpstest</frontName>
                </args>
            </vps_test>
        </routers>
    </frontend>
</config>

Observer.php

class VPS_Test_Model_Observer extends Mage_Core_Model_Abstract
{
    public function foo_test_front(Varien_Event_Observer $observer)
    {
        echo "foo_test event caught in observer FRONT";
    }


    public function foo_test_global(Varien_Event_Observer $observer)
    {
        echo "foo_test event caught in observer GLOBAL";
    }
}

Module Config XML

<config>
    <modules>
        <VPS_Test>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Core />
            </depends>
        </VPS_Test>
    </modules>
</config>

Next, to test this, I loaded http://my_domain/vpstest in my browser and I saw the expected output (i.e., it dispatched the event and my observer caught it)

I then created eventtest.php in the root of my site and hit that from my browser. In this case, Magento did fire the event, but my observer didn’t catch it.

eventtest.php

require 'app/Mage.php';
error_reporting(E_ALL | E_STRICT);
ini_set('html_errors', 1);
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);


try {
    Mage::app('');

    echo "event test<br/>";

    $foo = Mage::getModel('vps_test/observer');

    echo get_class($foo) . '<br />';

    Mage::dispatchEvent('test_event_one', array('object' => ''));
}
catch(Exception $e)
{
    echo "exception<br/>$e";
}

So….what am I NOT doing? Is it even possible to use the Magento event system without the full Magento app running?

Thanks!

  • 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-26T00:26:25+00:00Added an answer on May 26, 2026 at 12:26 am

    Typos will get you every time. In my config.xml, I had the <events>...</events> block outside the <global>...</global> block. Whoops… Fixing that fixed my problem.

    It’s important to note that in this case, the global area is the only area loaded by default. So to attach my event observer to an event when you’re just running Mage::app(''), you need to put it in the <global>...</global> section. Conversely, I believe WebFlakeStudio’s answer should work, though I haven’t tested it.

    Hope this helps someone.

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from

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.