Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento客户保存事件_Php_Magento_Events - Fatal编程技术网

Php Magento客户保存事件

Php Magento客户保存事件,php,magento,events,Php,Magento,Events,我正在处理现有的magento页面。登录用户可以更改其个人资料信息(名字、姓氏、电子邮件等),还可以更改其帐单和发货地址 我需要做的是在客户更改其基本信息或地址时发送通知电子邮件。我为两个事件创建了一个观察者: <frontend> <events> <customer_save_after> <observers> <ext_customer_save_afte

我正在处理现有的magento页面。登录用户可以更改其个人资料信息(名字、姓氏、电子邮件等),还可以更改其帐单和发货地址

我需要做的是在客户更改其基本信息或地址时发送通知电子邮件。我为两个事件创建了一个观察者:

<frontend>
    <events>
        <customer_save_after>
            <observers>
                <ext_customer_save_after>
                    <type>singleton</type>
                    <class>ext/observer</class>
                    <method>customerSaveAfter</method>
                </ext_customer_save_after>
            </observers>
        </customer_save_after>
        <customer_address_save_after>
            <observers>
                <ext_customer_save_after>
                    <type>singleton</type>
                    <class>ext/observer</class>
                    <method>customerAddressSaveAfter</method>
                </ext_customer_save_after>
            </observers>
        </customer_address_save_after>
    </events>
</frontend>

独生子女
分机/观察员
顾客储蓄
独生子女
分机/观察员
customerAddressSaveAfter
在发送电子邮件后的CustomerSave和在CustomerAddressSave中检查当前ID是否与defaultbillingaddress或defaultshipping地址相同,并相应地发送通知。在用户选中“设置为默认送货地址”复选框之前,这一切正常。在这种情况下,我突然收到5封电子邮件:

  • 帐单地址已更改
  • 装运地址已更改
  • 装运地址已更改
  • 帐单地址已更改
  • 客户信息已更改
因此,突然事件被触发多次,并且customer\u address\u save\u after以某种方式触发customer\u save\u after事件。有没有办法防止这种情况发生,或者检查是哪个事件触发了另一个事件或类似事件?还是有其他方法来处理这个问题


如果有任何提示,我将非常感谢,非常感谢

我无法真正解决这个问题,使用mage_registry时,我遇到了一个错误,所以我决定采用完全不同的方法

在我的扩展中,我删除了观察器,而是创建了两个新的控制器,AccountController和AddressController,以覆盖Magentos标准控制器来处理客户和地址保存

在我的config.xml中,我添加了以下内容:

<frontend>
    <routers>
        <customer>
            <args>
                <modules>
                    <my_ext before="Mage_Customer_AccountController">My_Ext</my_ext>
                    <my_ext before="Mage_Customer_AddressController">My_Ext</my_ext>
                </modules>
            </args>
        </customer>
    </routers>
</frontend>

我的电话号码
我的电话号码
例如,我的AccountController如下所示:

<?php
require_once Mage::getModuleDir('controllers','Mage_Customer').DS."AccountController.php";
class My_Ext_AccountController extends Mage_Customer_AccountController{
    public function editPostAction(){
        //I copied the code from the Magento AccountController here and at the proper line I added my own code
    }
}

我无法真正解决这个问题,因为我在mage_注册表中遇到了一个错误,所以我决定采用完全不同的方法

在我的扩展中,我删除了观察器,而是创建了两个新的控制器,AccountController和AddressController,以覆盖Magentos标准控制器来处理客户和地址保存

在我的config.xml中,我添加了以下内容:

<frontend>
    <routers>
        <customer>
            <args>
                <modules>
                    <my_ext before="Mage_Customer_AccountController">My_Ext</my_ext>
                    <my_ext before="Mage_Customer_AddressController">My_Ext</my_ext>
                </modules>
            </args>
        </customer>
    </routers>
</frontend>

我的电话号码
我的电话号码
例如,我的AccountController如下所示:

<?php
require_once Mage::getModuleDir('controllers','Mage_Customer').DS."AccountController.php";
class My_Ext_AccountController extends Mage_Customer_AccountController{
    public function editPostAction(){
        //I copied the code from the Magento AccountController here and at the proper line I added my own code
    }
}

您收到5封邮件,可能是因为每当客户更改任何数据(包括地址、基本档案信息等)时,都会触发-customer\u save\u after事件。而你的第二个客户地址在事件发生后会特别触发地址更改。但如果客户编辑地址,我只会收到一封电子邮件。只有选中复选框时才会触发customer_save_事件,因此这可能与您的问题有关,可以帮助您非常感谢。我最终选择了另一种方法,但你的链接仍然对我有帮助。你收到了5封邮件,可能是因为-customer_save_事件将在每次客户更改任何数据(包括地址、基本配置文件信息等)时触发。而你的第二个客户地址在事件发生后会特别触发地址更改。但如果客户编辑地址,我只会收到一封电子邮件。只有选中复选框时才会触发customer_save_事件,因此这可能与您的问题有关,可以帮助您非常感谢。我最终选择了另一种方法,但你的链接仍然帮助了我。