【问题标题】:Magento: getSingleton('customer/session') doesn't return information when called via SOAPMagento:通过 SOAP 调用时 getSingleton('customer/session') 不返回信息
【发布时间】:2014-07-26 22:50:17
【问题描述】:

我目前正在尝试在提交订单并使用观察者捕获 checkout_submit_all_after 事件后取回客户数据。如果我通过前端下订单,Mage::getSingleton('customer/session')Mage::getSingleton('checkout/session') run inside the observer 会给我大量信息,但是当我通过 SOAP 下订单时,这些方法什么也不返回。我也试过Mage::helper('customer')->getCustomer(),但它也没有返回任何东西。

还有其他方法可以获取上次提交订单的数据吗?具体来说,我需要会话中的客户和最后一个订单 ID ala Mage::getSingleton('checkout/session')->getLastRealOrderId()

【问题讨论】:

  • 查看生成 checkout_submit_all_after 事件的代码,$observer 变量应该有与订单相关的数据。然而这也是空的。目前正在研究为什么。
  • 好的,从 $observer['order']->getIncrementId() 得到 orderid。有趣的是 print_r 没有显示任何内容..
  • 差不多了.. 现在唯一的问题是我无法从订单或报价对象中获取电子邮件。进入创建报价的 API _prepareGuestQuote 它使用->setCustomerEmail($quote->getBillingAddress()->getEmail(),但是这是空白的!我什至试图通过在发送的值数组中设置“电子邮件”来作弊到 SOAP 的 shoppingCartCustomerAddresses 方法,但它不起作用。我知道电子邮件不会保存在客人购买中,但是电子邮件至少应该在订单结束之前可用!有什么想法吗?

标签: magento session soap singleton


【解决方案1】:

看看这个废话:quote->customer_email 字段最初是用电子邮件填充的,然后在使用 SOAP 方法“shoppingCartCustomerAddresses”设置地址后,来自 Checkout/Model/Api/Resource/Customer.php 的 _prepareGuestQuote 用"$quote->getBillingAddress()->getEmail())。哪个必须是空白的!为什么?看看地址对象的 wsdl 定义:

         <complexType name="shoppingCartCustomerAddressEntity">
            <all>
                <element name="mode" type="xsd:string" minOccurs="0"/>
                <element name="address_id" type="xsd:string" minOccurs="0"/>
                <element name="firstname" type="xsd:string" minOccurs="0"/>
                <element name="lastname" type="xsd:string" minOccurs="0"/>
                <element name="company" type="xsd:string" minOccurs="0"/>
                <element name="street" type="xsd:string" minOccurs="0"/>
                <element name="city" type="xsd:string" minOccurs="0"/>
                <element name="region" type="xsd:string" minOccurs="0"/>
                <element name="region_id" type="xsd:string" minOccurs="0"/>
                <element name="postcode" type="xsd:string" minOccurs="0"/>
                <element name="country_id" type="xsd:string" minOccurs="0"/>
                <element name="telephone" type="xsd:string" minOccurs="0"/>
                <element name="fax" type="xsd:string" minOccurs="0"/>
                <element name="is_default_billing" type="xsd:int" minOccurs="0"/>
                <element name="is_default_shipping" type="xsd:int" minOccurs="0"/>
            </all>
        </complexType>

您在其中看到“电子邮件”字段吗?我当然不会! 所以现在我必须重写它以使其具有功能。真的 Magento,wtf?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 2018-10-12
    • 2019-07-21
    • 1970-01-01
    相关资源
    最近更新 更多