How to invoke $customer->save() on a given event
So I've been tasked with creating a module to login/register a customer in Magento based on existing authentication data from another system. My thought for now is to create a Widget that can be placed by the admin with links. That part I've figured out how to do.
The next part is where I may need some assistance. I've read enough articles to understand how to create a custom URL structure in order to fire my Module's actions, so I assume I can link directly to my action, invoke a login or registration request and send the user back to the referral page (or their profile page, I haven't spec'd the project fully so details like this are TBD).
Here's where I need some help. I've found the methods that capture the POST request by the login and registration pages -- should I simply extend the Mage_Customer_Account开发者_如何学GoController class and create my required methods loosely similar to the calls used in loginPostAction() and createPostAction() methods?
For reference, I just started some initial project dev on a fresh install of the newly-released 1.5.0.0 The file I'm referring to is
/magento/app/code/core/Mage/Customer/controllers/AccountController.php
All event-based behavior in Magento should be handled within the event/observer methods (more information can be found here).... for instance to call your own actions on a customer login would subscribe to the customer_login or customer_logout events. If you are trying to subscribe to an event on customer save in the admin area it would be the adminhtml_customer_save_after event. A full list of these for 1.4.2 can be found here.
Another word of caution - overloading controllers is something I would do sparingly. Most of what you're trying to do can be accomplished by making your own controllers and using the Zend forward() method to forward to your desired controller method (you mentioned loginPostAction() in Mage_Customer_AccountController) after getting your functionality in ahead of time.
精彩评论