How to automatically send a transactional email on customer group change?
-
12-12-2019 - |
Question
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,
Solution
Hi 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
Model Approach
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 */
}
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange