Is there an event for customer account registration in Magento?

后端 未结 17 1867
轻奢々
轻奢々 2020-12-04 17:23

I would like to be able to run some functionality with a module that I am building whenever a customer registers an account, but I can\'t seem to f

相关标签:
17条回答
  • 2020-12-04 17:45

    customer_register_success

    adminhtml_customer_save_after

    these two are the default events when a customer is inserted into the database.... first event fires in frontend when a user registers and second event fires in the backend when a customer is created through admin panel...i hope you know how to register an observer for an event...hope this will help you...

    0 讨论(0)
  • 2020-12-04 17:49

    customer_register_success is what you are looking for:

    <config>
      <frontend>
        <events>
          <customer_register_success>
            <observers>
              <your_module>
                <type>singleton</type>
                <class>your_module/observer</class>
                <method>yourMethod</method>
              </your_module>
            </observers>
          </customer_register_success>
        </events>
      </frontend>
    </config>
    
    0 讨论(0)
  • 2020-12-04 17:50

    Actually there are customer_save_after and customer_save_before (magento 1.5)

    If you want to modify on-the-fly some data after form post, pick customer_save_before, change the data you want and that's all (the save action come after, so your change will be taken into account).

    $customer->save() just doesn't work in customer_save_after. (fatal error) Use this observer to run a code after customer creation which are NOT related to customer data.

    Hope that helps!

    0 讨论(0)
  • 2020-12-04 17:54

    I've discovered that the customer_login and customer_session_init events are both thrown on account create. You could register a listener for either and then check to see the create date on the account?

    0 讨论(0)
  • 2020-12-04 17:55

    You have to consider also when the user register on-the-fly on checkout: a Register on chekout. Thinking on this case, you can catch the "checkout_type_onepage_save_order_after" event with your own Observer class, and then this code...

    
    if($observer->getEvent()->getQuote()->getCheckoutMethod(true) == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER){
        (...)
    }

    Anybody may say: Mage_Sales_Model_Quote->getCheckoutMethod() is deprecated since 1.4!!,but:

  • If we call the ortodox method Mage_Checkout_Model_Type_Onepage->getCheckoutMethod(), waiting for something as "METHOD_REGISTER" this is executed:

    if ($this->getCustomerSession()->isLoggedIn()) {
                return self::METHOD_CUSTOMER;
            }

    ... "METHOD_CUSTOMER" is the name for a checkout with an already registrated user, not our case.... but yes!, because....

  • ...the registration operation is perfomed before "checkout_type_onepage_save_order_after" event. Then we a have a METHOD_CUSTOMER now. Ups, something inconsistent?

  • Fortunatly, the Quote remains with the original value: CHECKOUT_METHOD_REGISTER

    Any other idea for the registration on checkout?

0 讨论(0)
提交回复
热议问题