【问题标题】:Filtering Magento SOAP requests using Zeep使用 Zeep 过滤 Magento SOAP 请求
【发布时间】:2019-02-02 11:17:55
【问题描述】:

我正在努力从 Python 2.7 向 Magento 的 SOAP 服务发送过滤器。我正在尝试使用 Zeep 包来调用 SOAP 服务。发送一个空列表作为第二个参数可以很好地返回所有数据。但是,当我在第二个参数中设置过滤器时,它会被忽略,我仍然会得到所有数据。提前致谢!

from zeep import Client

client = Client('https://mywebsite.com/api/v2_soap/index/?wsdl=1')

token = client.service.login('myusername', 'mypassword')

# This works fine, returns all of the customers
customer_list = client.service.customerCustomerList(token, [])

# This still returns all of the customers and ignores the filter
filter = [{'created_at': {'from': '2018-07-01 00:00:00'}}]
customer_list_filtered = client.service.customerCustomerList(token, filter)

我不确定它是否相关,但我收到了这些警告。

C:\Users\some_path_to_python\lib\site-packages\zeep\wsdl\wsdl.py:335: UserWarning: The wsdl:message for u'{urn:Magento}channelintegrationOrderInfoResponse' contains an invalid part ('result'): invalid xsd type or elements
  warnings.warn(str(exc))
C:\Users\some_path_to_python\lib\site-packages\zeep\wsdl\definitions.py:130: UserWarning: The wsdl:operation 'channelintegrationOrderInfo' was not found in the wsdl:portType u'{urn:Magento}PortType'
  warnings.warn(str(exc))

【问题讨论】:

    标签: python python-2.7 magento soap zeep


    【解决方案1】:

    就我而言,我必须正确格式化过滤器。按照文档中的示例 - https://devdocs.magento.com/guides/m1x/api/soap/sales/salesOrder/sales_order.list.html#sales_order.list-Examples 我必须编写这样的过滤器

    filters = [{
        'filter': {
            'complexObjectArray': [{
                'key': 'status',
                'value': 'pending'
            }]
        },
        'complex_filter': {
            'complexObjectArray': [{
                'key': 'status',
                'value': {
                    'key': 'in',
                    'value': 'pending,processing'
                }
            }]
        }
    }]
    

    换句话说,将所有内容包装在 complexObjectArray 中以使其工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多