让Magento在收到付款时发送电子邮件 [英] Getting Magento to send email when a payment is received

查看:61
本文介绍了让Magento在收到付款时发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不认为Magento有一种开箱即用的方法,可以在收到付款后发送电子邮件通知所有者,因此可以通过任何方式对此进行编程吗?

I don't believe Magento has an out of box method of sending an email to inform the owner when a payment has been received so is there any way that this can be programmed?

到目前为止,我已经阅读了,但看起来像可能更专注于将电子邮件发送给客户而不是供应商;和,但除了完全丢失(从OP的声音来看)一个人说接受的答案有点过时了,而且我也不知道这是我所需要的.

So far I have read this but it looks like it might be more focused on sending the email to the customer instead of the vendor; and this but apart from being completely lost ( as by the sound of it was the OP ) one person said accepted answer was a bit out of date and also I'm not sure it's what I need anyway.

推荐答案

基本上,您需要(惊奇的)观察者模块来做到这一点.此外,它与中的一项工作完全相同您提供的链接.

Basically, what you need is (surprise) an observer module to do exactly that. Also, it is quite the same work in one of the links you provided.

要制作准系统的观察器模块,您只需要三个文件:

To make a barebones observer module, you only need three files:

/app/etc/modules/Electricjesus_Notifyowner.xml

/app/etc/modules/Electricjesus_Notifyowner.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Electricjesus_Notifyowner>
            <active>true</active>
            <codePool>local</codePool>
        </Electricjesus_Notifyowner >
    </modules>
</config>

/app/code/local/Electricjesus/Notifyowner/etc/config.xml

/app/code/local/Electricjesus/Notifyowner/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Electricjesus_Notifyowner>
                <version>0.1.0</version>
        </Electricjesus_Notifyowner>
    </modules>
    <global>
        <models>
            <notifyowner>
                <class>Electricjesus_Notifyowner_Model</class>
            </notifyowner>
        </models>          
        <events>
                <sales_order_payment_pay>
                    <observers>
                        <notifyOwnerEvent>
                                <class>notifyowner/observer</class>
                                <method>notifyOwnerEvent</method>
                        </notifyOwnerEvent>
                    </observers>
                </sales_order_payment_pay >     
        </events>
     </global>
</config>

/app/code/local/Electricjesus/Notifyowner/Model/Observer.php

/app/code/local/Electricjesus/Notifyowner/Model/Observer.php

<?php
class Electricjesus_Notifyowner_Model_Observer
{
    public function notifyOwnerEvent($observer)
    {

        // parameters you can get from the $observer parameter:
        // array(’payment’ ? $this, ‘invoice’ ? $invoice)

        $payment = $observer->getPayment();
        $invoice = $observer->getInvoice();

        // derivative data
        $order = $invoice->getOrder(); // Mage_Sales_Model_Order

        $ownerEmail = 'owner@shop.com';
        /*
             - build data
             - build email structure
             - send email via any php mailer method you want
        */
        return $this;  // always return $this.
    }

}

您还可以使用其他事件代替sales_order_payment_pay(请参见config.xml).请参阅此列表以获取事件及其事件的半完整列表参数.在此文档上,这是一些技巧检查/获取具有其参数的当前事件列表的更新.

You can also use other events in place of sales_order_payment_pay (see config.xml). See this list for a semi-complete list of events along with their parameters. And on this document to is some techniques to check/get an update of the current list of events with their parameters.

我建议使用Zend_Mail在观察器中处理您的邮件.没什么特别的,我只是偏向Zend.

I recommend using Zend_Mail to do your mail stuff inside the observer. Nothing special, I'm just biased towards Zend stuff.

http://framework.zend.com/manual/en/zend .mail.html

---编辑

如果您想要现成的扩展程序来执行此操作(以及更多操作),并且如果您不介意为此付费,则可以看看:

if you want a ready-made extension to do this (and more) and if you do not mind paying for it, you can take a look at:

http://www.magentocommerce.com/magento-connect /admin-email-notifications.html

这篇关于让Magento在收到付款时发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆