使用Python创建使用Magento API的客户时,我收到此错误:
Fault 1: "SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s), query was: SELECT `customer_entity`.* FROM `customer_entity` WHERE (entity_id ='firstname', '3876')"
但是,如果我只指定客户ID,它将询问所有其他字段,当我用这些值扩展dict时,同样的错误再次出现。 这是我用来创建客户的字典:
address = {}
address['customer_id'] = '3876'
address['addressdata']={}
address['addressdata']['firstname'] = 'firstname'
address['addressdata']['lastname'] = 'lastname'
address['addressdata']['city'] = 'city'
address['addressdata']['region'] = 'Texas'
address['addressdata']['region_id'] = 1
address['addressdata']['postcode'] = '23423' #ZIP
address['addressdata']['telephone'] = '3245235235' #phone
address['addressdata']['is_default_billing'] = False
address['addressdata']['is_default_shipping'] = False
address = proxy.call(session, 'customer_address.create', [address])
你觉得这里有什么不对吗?感谢
答案 0 :(得分:0)
在服务器端,启用sql日志记录(理想情况下,只有您的API调用应针对该服务器运行,以便进行调试):
在Varien_Db_Adapter_Pdo_Mysql
lib/varien/Db/Adapter/Pdo/Mysql.php
组
protected $_debug = true;
protected $_logAllQueries = true;
和(如果还没有)创建
中定义的文件夹protected $_debugFile = 'var/debug/sql.txt';
运行API调用,然后查看日志文件,查看运行的查询及其出错的原因。
您也可以针对同一问题尝试以下链接,可能对您有所帮助。
https://stackoverflow.com/a/14864123