1

Whenever a new customer is created or modified, I want to add a new custom attribute into that customer.

I've created a customer observer but I'm obviously getting an infinite loop. When updating the customer, the observer is called and the new attribute is saved so the observer is called again and again...

These are my observers:

<events>
  <customer_save_after>
    <observers>
      <mycompany_customer_observer>
        <type>singleton</type>
        <class>mycompany_customer/observer</class>
        <method>addVisa</method>
      </mycompany_customer_observer>
    </observers>
  </customer_save_after>
  <customer_register_success>
    <observers>
      <mycompany_customer_observer>
        <type>singleton</type>
        <class>mycompany_customer/observer</class>
        <method>addVisa</method>
      </mycompany_customer_observer>
    </observers>
  </customer_register_success>
</events>

How can I store a new attribute in the customer whenever it's created or updated?

1 Answer 1

1

You'll have to include your observer methods to complete your question, but my guess is that you're doing $customer->save() in your customer_save_after observer. If you are, this will continue firing the event customer_save_after and go on forever.

If this is the case, what you need to do is create an observer that listens to something like customer_save_before and set you data onto $customer, and let it get saved automatically. You need only one observer to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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