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
 
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
 
demonkoryu
Guru
 
Avatar
Total Posts:  328
Joined:  2008-11-26
Dortmund, Germany
 

@magentoadmindeveloper, please don’t spam in unrelated threads.
Your post here should be enough.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bishop155
Jr. Member
 
Total Posts:  2
Joined:  2009-10-01
 

I’m having troube with controller_action_noroute event, it apears that is never gets called, because the method it is called in is overridden by the cms module, is there a nice way around this without modifying the any of the core code?, tks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
butterbrot
Member
 
Total Posts:  52
Joined:  2008-10-26
 

I am missing an event in Newbound_Checkout_Model_Cart::addOrderItem()

/**
     * Convert order item to quote item
     *
     * @param Mage_Sales_Model_Order_Item $orderItem
     * @param mixed $qtyFlag if is null set product qty like in order
     * @return Mage_Checkout_Model_Cart
     */
    public function addOrderItem($orderItem$qtyFlag=null)
    
{
        
/* @var $orderItem Mage_Sales_Model_Order_Item */
        
if (is_null($orderItem->getParentItem())) {
            $product 
Mage::getModel('catalog/product')
                ->
setStoreId(Mage::app()->getStore()->getId())
                ->
load($orderItem->getProductId());
            if (!
$product->getId()) {
                
return $this;
            
}

            $info 
$orderItem->getProductOptionByCode('info_buyRequest');
            
$info = new Varien_Object($info);
            if (
is_null($qtyFlag)) {
                $info
->setQty($orderItem->getQtyOrdered());
            
else {
                $info
->setQty(1);
            
}

            
// @todo add event

            
$this->addProduct($product$info);
        
}
        
return $this;
    
}

Would be nice to have something like this here

Mage::dispatchEvent('checkout_cart_add_order_item', array(
    
'order_item' => $orderItem
    
'buy_request' => $info
    
'product' => $product
));

Am I better off login this in the bug-list as feature or is it enough having it posted here? smile

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
manchuck
Jr. Member
 
Avatar
Total Posts:  7
Joined:  2009-08-20
 

If the admins are still taking requests for events, I would like to request that an event gets fired when the customer saves an address (billing or shipping it doesnt matter).  I need to run the address through a translation service and save the translated address.

 
Magento Community Magento Community
Magento Community
Magento Community
 
butterbrot
Member
 
Total Posts:  52
Joined:  2008-10-26
 

Hey customers are extending the Mage_Core_Model_Abstract class which fire an event

Mage_Customer_Model_Address_Abstract
protected $_eventPrefix = ‘customer_address’;
protected $_eventObject = ‘customer_address’;

Mage::dispatchEvent($this->_eventPrefix.’_save_before’, array($this->_eventObject=>$this));

 
Magento Community Magento Community
Magento Community
Magento Community
 
smily
Jr. Member
 
Avatar
Total Posts:  15
Joined:  2008-05-05
Sydney, Australia
 

There appears to be postDispatch() and preDispatch() functions inside Mage_Core_Controller_Varien_Action which dispatch an event before and after a controller action is called based on the request route name. So the event would be:

controller_action_postdispatch_<the route name>_<the controller name>_<the action name>

Doesn’t give you much info but you can get the request params from the url.

 
Magento Community Magento Community
Magento Community
Magento Community
 
butterbrot
Member
 
Total Posts:  52
Joined:  2008-10-26
 

Hey

I am not to happy with the events in creditmemp:refund

Mage_Sales_Model_Order_Creditmemo::refund()

public function refund()
    
{
        $this
->setState(self::STATE_REFUNDED);
        
$orderRefund Mage::app()->getStore()->roundPrice($this->getOrder()->getTotalRefunded()+$this->getGrandTotal());
        
$baseOrderRefund Mage::app()->getStore()->roundPrice($this->getOrder()->getBaseTotalRefunded()+$this->getBaseGrandTotal());

        if (
$baseOrderRefund Mage::app()->getStore()->roundPrice($this->getOrder()->getBaseTotalPaid())) {

            $baseAvailableRefund 
$this->getOrder()->getBaseTotalPaid()
                - 
$this->getOrder()->getBaseTotalRefunded();

            
Mage::throwException(
                
Mage::helper('sales')->__('Maximum amount available to refund is %s',
                    
$this->getOrder()->formatBasePrice($baseAvailableRefund)
                )
            );
        
}

        $this
->getOrder()->setBaseTotalRefunded($baseOrderRefund);
        
$this->getOrder()->setTotalRefunded($orderRefund);

        
$this->getOrder()->setBaseSubtotalRefunded(
            
$this->getOrder()->getBaseSubtotalRefunded()+$this->getBaseSubtotal()
        );
        
$this->getOrder()->setSubtotalRefunded(
            
$this->getOrder()->getSubtotalRefunded()+$this->getSubtotal()
        );

        
$this->getOrder()->setBaseTaxRefunded(
            
$this->getOrder()->getBaseTaxRefunded()+$this->getBaseTaxAmount()
        );
        
$this->getOrder()->setTaxRefunded(
            
$this->getOrder()->getTaxRefunded()+$this->getTaxAmount()
        );

        
$this->getOrder()->setBaseShippingRefunded(
            
$this->getOrder()->getBaseShippingRefunded()+$this->getBaseShippingAmount()
        );
        
$this->getOrder()->setShippingRefunded(
            
$this->getOrder()->getShippingRefunded()+$this->getShippingAmount()
        );

        
$this->getOrder()->setBaseShippingTaxRefunded(
            
$this->getOrder()->getBaseShippingTaxRefunded()+$this->getBaseShippingTaxAmount()
        );
        
$this->getOrder()->setShippingTaxRefunded(
            
$this->getOrder()->getShippingTaxRefunded()+$this->getShippingTaxAmount()
        );

        
$this->getOrder()->setAdjustmentPositive(
            
$this->getOrder()->getAdjustmentPositive()+$this->getAdjustmentPositive()
        );
        
$this->getOrder()->setBaseAdjustmentPositive(
            
$this->getOrder()->getBaseAdjustmentPositive()+$this->getBaseAdjustmentPositive()
        );

        
$this->getOrder()->setAdjustmentNegative(
            
$this->getOrder()->getAdjustmentNegative()+$this->getAdjustmentNegative()
        );
        
$this->getOrder()->setBaseAdjustmentNegative(
            
$this->getOrder()->getBaseAdjustmentNegative()+$this->getBaseAdjustmentNegative()
        );

        
$this->getOrder()->setDiscountRefunded(
            
$this->getOrder()->getDiscountRefunded()+$this->getDiscountAmount()
        );
        
$this->getOrder()->setBaseDiscountRefunded(
            
$this->getOrder()->getBaseDiscountRefunded()+$this->getBaseDiscountAmount()
        );

        if (
$this->getInvoice()) {
            $this
->getInvoice()->setIsUsedForRefund(true);
            
$this->setInvoiceId($this->getInvoice()->getId());
        
}

        
if (!$this->getPaymentRefundDisallowed()) {
            $this
->getOrder()->getPayment()->refund($this);
        
}

        Mage
::dispatchEvent('sales_order_creditmemo_refund', array($this->_eventObject=>$this));
        return 
$this;
    
}

The event gets dispatched after the payment model made the refund,
there should be one before this happends

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sweet Tooth
Sr. Member
 
Avatar
Total Posts:  121
Joined:  2008-02-02
Canada
 

The reward points extension for Magento called Sweet Tooth does a heavy rewrite of the customer model in order to monitor the new customer create event.  I wish we didn’t have to do it like that, but when we were developing it originally I couldn’t find the event being dispatched in the records.  After playing around with the save_after and save_before dynamic events, we ended up just rewriting the entire customer model. 

Now, in Sweet Tooth 1.3 we’ve programmed in a dispatch event for new customer creation so that extensions to Sweet Tooth, or any other modules that rely on Sweet Tooth functionality, can utilize the event and react as needed. The event code is “rewards_new_customer_create”.

Also, it’s important to note the difference between new customer creation and customer registration events.  Customer registration can only occur in the frontend, and for that we would do a postdispatch or predispatch dynamic event reaction, however the ‘new customer’ even would react to the creation of a customer no matter where it’s done and no matter how it’s done.

Is there a ‘new customer’ event dispatched for any version of Magento yet so we don’t have to keep our own?  If not, I’d like to request that it be considered.

 
Magento Community Magento Community
Magento Community
Magento Community
 
zorancho
Jr. Member
 
Total Posts:  9
Joined:  2009-12-23
 

As far as i could understand about the Observer - Events pattern in Magento and by looking at the core code, i could see Mage::dispatchEvent() being called on lots of places, but some of the events being thrown are not caught by Observer, so when i see something like this for example:

Mage::dispatchEvent('checkout_cart_add_product_complete',
                array(
'product' => $product'request' => $this->getRequest(), 'response' => $this->getResponse())
            );

Could i watch for this event (or any other predefined events) in my custom module etc/config.xml file since some of the Magento events are not being caught.

<events>
          <
checkout_cart_add_product_complete>
            <
observers>
              <
my_own_observer>
                <
type>singleton</type>
                <class>
my_module/observer</class>
                <
method>my_method</method>
              </
my_own_observer>
            </
observers>
          </
checkout_cart_add_product_complete>
   </
events>

Thanks for your time

 
Magento Community Magento Community
Magento Community
Magento Community
 
ignite
Jr. Member
 
Total Posts:  1
Joined:  2009-07-30
 

Is there an event that gets fired when someone changes the status in bulk using the actions dropdown in the Manage Products grid admin?

 
Magento Community Magento Community
Magento Community
Magento Community
 
mariaapee243
Jr. Member
 
Total Posts:  10
Joined:  2010-04-29
 

hello all
thanks for sharing nice ideas.... keep it up

 
Magento Community Magento Community
Magento Community
Magento Community
 
bertojhone
Jr. Member
 
Total Posts:  10
Joined:  2010-05-03
 

You guys have shared quite helpful ideas ...Thanks.

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