我是新的Magento,我需要发送电子邮件到一个特定的管理员当另一个管理员在Magento创建一个新产品。
请问,我该如何实现它?谢谢!
-
在global-tag或更好的adminhtml-tag中添加事件到模块的config.xml
... <events> <catalog_product_save_after> <observers> <yourmodule> <type>singleton</type> <class>yourmodule/observer</class> <method>sendTransactionalMail</method> </yourmodule> </observers> </catalog_product_save_after> </events>
-
在你的观察者类yourmodule/observer中,它实际上是Your_Module_Model_Observer只需发送交易邮件:
public function sendTransactionalMail(){
$senderName = 'NAME'; $senderEmail = 'your@email.com'; $sender = array('name' => $senderName,'email' => $senderEmail); $storeId = Mage::app()->getStore()->getId(); $vars = array('subject' => 'Product Save Notification'); $transactionalEmail= Mage::getModel('core/email_template')->setDesignConfig(array('area'=>'frontend', 'store'=>$storeId)); //create a new template via adminhtml and grab the id $emailTemplateId = 17; $transactionalEmail->sendTransactional($emailTemplateId, $sender, $recepientEmail, "Admin", $vars); }
我将为catalog_product_new_action事件或catalog_product_prepare_save事件创建一个观察者,然后发送事务。
创建观察者教程http://www.pierrefay.com/event -观察家线上购物教程- howto - 105
发送事务教程:http://www.excellencemagentoblog.com/magento-sending-custom-emails