I would like to send a custom transactional email automatically to a user when he is assigned to a specific user group.
I think doing that with on observer but do not manage to find which event to trigger…
Thank you for your help,
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityHi you can do this by magento event Observer and find a trigger an observer on customer save after and fire send your custom transactional email automatically.
You can try this Two Event
customer_save_before
customer_save_after
Find details on event and observer here
Step1: trigger an event on basic of customer_save_after
<global>
<events>
<customer_save_after>
<observers>
<stockalert>
<type>singleton</type>
<class>magento37890/observer</class>
<method>checkDisplay</method>
</stockalert>
</observers>
</customer_save_after>
</events>
</global>
Step2: Magento Observer Code is
<?php
class Stackexchange_Magento37890_Model_Observer
{
public function checkDisplay(Varien_Event_Observer $observer){
$customer=$observer->getEvent()->getCustomer();
Mage::log('My log entry'.$customer->getId(), null, 'Magento37890.log');
/* if customer is old customer */
if($customer->getId()){
if($customer->getOrigData('group_id')!=$customer->getData('group_id')){
/* here you write your code to send whenever you have change the group */
}
}else{
/* New Customer */
}
}
}
$customer->getId()
under the event customer_save_after
to determine if the customer is new would not work. Since the event is AFTER save, there will always be an id. You can determine if the customer is in fact new by checking the state of $customer->getOrigData()
- if it is NULL, there was no previous data, so is assumed a new record.
Jan 7, 2016 at 2:57