0

I want to execute my code once when a customer is loaded in the admin area, I use the customer_load_after event to do that, the problem, I have the method is triggered three times, and I only need one.

I tried to use a flag protected $_firstTime, and I tried to put it in a contructor too, but nothing works because the class is instantiated every time.

didn't work either:

  • the register/registry

  • customer_load_before

I'm specifing in the oberser <type>singleton</type> But nothing works.

any idea?

  • Did you try using Mage::register('XXXX')? – Raul Sanchez Aug 8 '18 at 10:45
  • If registry doesn't work I would try something like this magento.stackexchange.com/questions/50244/… – Raul Sanchez Aug 8 '18 at 10:51
  • @ooootramas You want to an event when a customer form loaded in admin right? for this there is no such event, you can use event 'adminhtml_customer_prepare_save' and 'adminhtml_customer_save_after' these will work before save and after save customer data.otherwise you need to overwrite admin customer controller. – Charul Tyagi Aug 8 '18 at 10:53
  • @CharulTyagi, I prefer to have the new information in customer load, not only when someone press the button 'save' – ooootramas Aug 8 '18 at 11:11
  • @ooootramas Magento admin does not provide such type of event you please try to overwrite its method of controller by which it is working to load customer form. – Charul Tyagi Aug 8 '18 at 11:45
0

The flag way should work, Here's code I use in one of my projects to achieve what you're trying to.

class Vendor_Modulename_Model_Observer
{

    public $eventComplete = false;

    function sales_quote_collect_totals_after()
    {

        if($this->eventComplete){return;}

        $this->eventComplete = true;

       // put module code below here

     }

}
  • Doesn't work. I use a flag in other situations and it worked, but I don't know if it's something about the event, or beacuse it's been triggered in the admin. – ooootramas Aug 8 '18 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.