Reputation: 21
I'm struggling with sending a filter to Magento's SOAP service from Python 2.7. I'm attempting to use the Zeep package to call the SOAP service. Sending an empty list as the second argument works fine to return all of the data. However when I set a filter in the second argument it is ignored and I still get all of the data. Thanks in advance!
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)
I'm not sure if it's relevant or not but I'm getting these warnings.
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))
Upvotes: 0
Views: 764
Reputation: 1845
In my case, I had to correctly format the filters. Following the examples in docs - https://devdocs.magento.com/guides/m1x/api/soap/sales/salesOrder/sales_order.list.html#sales_order.list-Examples I had to write filters like this
filters = [{
'filter': {
'complexObjectArray': [{
'key': 'status',
'value': 'pending'
}]
},
'complex_filter': {
'complexObjectArray': [{
'key': 'status',
'value': {
'key': 'in',
'value': 'pending,processing'
}
}]
}
}]
so in other words, wrap everything in complexObjectArray to get it work.
Upvotes: 0