Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Event dispatch requests
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

I need an event when the user removes an item from the cart.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

@Classy Llama Studios

Thanks for the tip, I’ve been looking for that for a few days, I guess I didn’t search hard enough.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tman_f
Sr. Member
 
Total Posts:  85
Joined:  2008-02-12
 

Events are great.

What I need to do is create my very own event. This becomes quite necessary as systems become complex and stretch above the “out-of-the-box” features.

This is what I need to do:

Mage::dispatchEvent(’my_very_own_event’);

I have registered observers for this event, but nothing seems to happen when I dispatch my own event. Am I missing something?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
tman_f
Sr. Member
 
Total Posts:  85
Joined:  2008-02-12
 

Here is the event I am firing:

Mage::dispatchEvent(’reset_checkout’);

And here is my config.xml entry:

<global>
<events>
<reset_checkout>
<observers>
<rollback_giftcard_redemption>
<type>singleton</type>
<class>giftcard/sales_quote_reset</class>
<method>rollbackGiftcardRedemption</method>
</rollback_giftcard_redemption>
</observers>
</reset_checkout>
</events>
</global>

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

@class Llama Studios
Actually, that is incorrect. He had it correct by specifying the {shortname}/{relative class name} in his XML config

@tman_f
As for why your event handler is not working, try putting it in the <frontend><events> section and see if that changes anything.

 
Magento Community Magento Community
Magento Community
Magento Community
 
boomography
Jr. Member
 
Avatar
Total Posts:  14
Joined:  2009-04-15
Madeira Beach, FL
 

I am having trouble getting an event observer to trigger.  Here’s the code…

app/etc/modules/Boom.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <
modules>
        <
Boom_Order>
            <
codepool>local</codepool>
            <
active>true</active>
        </
Boom_Order>
    </
modules>
</
config>

app/code/core/local/Boom/Order/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <global>
        <
models>
            <
boomorder>
                <class>
Boom_Order_Model</class>
            </
boomorder>
        </
models>
    </global>
    <
frontend>
        <
events>
            <
checkout_onepage_controller_success_action>
                <
observers>
                    <
boom_order_observer>
                        <
type>singleton</type>
                        <class>
boomorder/observer</class>
                        <
method>myOrderProcess</method>
                    </
boom_order_observer>
                </
observers>
            </
checkout_onepage_controller_success_action>
        </
events>
    </
frontend>
</
config>

app/code/core/local/Boom/Order/Model/Observer.php

<?php

class Boom_Order_Model_Observer
{
    
/**
     * Event Hook: checkout_onepage_controller_success_action
     * @param $observer Varien_Event_Observer
     */

    
public function myOrderProcess($observer)
    
{
        Mage
::log("Enter myOrderProcess");

        
$order = new Mage_Sales_Model_Order();
        
$incrementId Mage::getSingleton('checkout/session')->getLastRealOrderId();

        
$order->loadByIncrementId($incrementId);

        
Mage::log("Exit myOrderProcess");
        
}
}
I’m sure it is something silly but I have been beating my forehead flat on this.
 
Magento Community Magento Community
Magento Community
Magento Community
 
SebboKleine
Jr. Member
 
Total Posts:  23
Joined:  2008-07-10
 

@boom
Can you call your observer directly (Mage::getSingleton(’boomorder/observer’);)? Because you named it boomorder instead of order in your config.xml, Magento might not be able to find it.

<global>
<models>
<boomorder> (should be order)
<class>Boom_Order_Model</class>
</boomorder>
</models>
</global>

 
Magento Community Magento Community
Magento Community
Magento Community
 
rainman127
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-06-30
 

Hi
in: app/code/core/local/Boom/Order/etc/config.xml

try changing

<class>boomorder/observer</class>

to

<class>boom_order_model_observer</class>

 
Magento Community Magento Community
Magento Community
Magento Community
 
SBC Fulfillment
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2009-07-06
 

Hey all, I’m a bit new to all this but so far Magento is rocking!

I’m in the process of writing a module and I’m using the “sales_order_place_after” event to trigger my code.  Everything seems fine except I’m having trouble getting an order ID out of the event object.

$order$observer->getEvent()->getOrder();

is giving me the Mage_Sales_Model_Order Object when I print_r it out to a file and I can see the order number in there but

$id$observer->getEvent()->getOrder()->getId();

gives me nothing and no errors in the browser or server logs :(
Am I missing something simple here?

Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
SBC Fulfillment
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2009-07-06
 

When I dumped the order object and did a quick search for the order number I had just created I found it in the file, but unfortunately it’s buried amongst so much other stuff I gave up on trying to figure out the hierarchy it was under.

I still don’t know the reason getId() didn’t work, but I was able to extract the order number like:

$order$observer->getEvent()->getOrder()->increment_id;

If you have any recommendations for a good book or two that would help with this kind of stuff I’m all ears smile

Thanks again!

 
Magento Community Magento Community
Magento Community
Magento Community
 
SBC Fulfillment
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2009-07-06
 

Yeah, now that I’m getting into this kind of thing more and more often I think it’s time to step it up a notch and bust out some new tools.  I was mainly after something related to Magento programming, although so far these forums seem to be the best resource.  Well, back to the trenches for me

 
Magento Community Magento Community
Magento Community
Magento Community
 
inertia1024
Jr. Member
 
Total Posts:  14
Joined:  2009-06-15
 
xerxes2695 - 07 August 2009 04:50 AM

I still don’t know the reason getId() didn’t work, but I was able to extract the order number like:

$order$observer->getEvent()->getOrder()->increment_id;

I was having exactly the same issue with the sales_order_place_after event.  Incidentally, I noticed that $order->getCustomerId() also returns null if the order is placed by a new customer.  My only guess is that this event fires somewhere before the order is committed.

I’ve switched to using the sales_order_invoice_pay event for my module… I can get the order through the $invoice->getOrder, and everything seems to be working now.

 
Magento Community Magento Community
Magento Community
Magento Community
 
SBC Fulfillment
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2009-07-06
 
inertia - 18 August 2009 12:56 AM

xerxes2695 - 07 August 2009 04:50 AM

I still don’t know the reason getId() didn’t work, but I was able to extract the order number like:
$order$observer->getEvent()->getOrder()->increment_id;

I was having exactly the same issue with the sales_order_place_after event.  Incidentally, I noticed that $order->getCustomerId() also returns null if the order is placed by a new customer.  My only guess is that this event fires somewhere before the order is committed.

I’ve switched to using the sales_order_invoice_pay event for my module… I can get the order through the $invoice->getOrder, and everything seems to be working now.

I think you’re right.  Some of the API calls I was testing with were also failing.  You can always commit the order yourself with $order->save(); although if your module code has a problem after that point then the customer will get an error message even though the order was saved.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jc23
Jr. Member
 
Avatar
Total Posts:  12
Joined:  2009-05-07
Atlanta
 

@boomography

Any luck on this. I’m trying to do something similar. Thanks,

James

 
Magento Community Magento Community
Magento Community
Magento Community
 
magentoadmindeveloper
Jr. Member
 
Total Posts:  6
Joined:  2009-09-13
 

Hi All,

I have a doubt .Please help me.

In the front end section , I am providing an interface for downloading the uploaded files by the admin

I am using a phtml file , where all the uploaded files will be listed.
All the (listed) uploaded files will be having a link. In the link , means inside the <a href>. I am calling a javascript function which sets a hidden variable and submits to the same page.Once this hidden variable is set , I am calling a php function which is written in the corresponding class file. Inside the function I am calling the following code

header("Content-Type: $filetype");
header("Content-Disposition: attachment; filename=$file");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");

I need the file to be downloaded with a (save or open) prompt. I am getting the prompt. while I am trying to save the file, I can download the file. But the downloaded file content is having all the html page source with it.

I have tried using ob_start(),ob_end_clean(),ob_clean() etc.. before sending the file/output to the browser Still its not working

the files I am using is present in the following folders

/app/code/local/company/New/Block/New.php(this is the class file where the php function resides)

/app/design/frontend/company/default/template/new/new.phtml(this is the phtml file )

Thanks and Regard

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top