简体   繁体   English

在Prestashop上按SKU在购物车中添加产品

[英]Adding products in cart by sku on prestashop

I'm using prestashop webservice for an integration, 我正在使用prestashop网络服务进行集成,

I'm sending throw POST http://url/prestashop/api/carts?schema=blank&ws_key=MYKEY=keywords&language=1 我正在发送引发POST http:// url / prestashop / api / carts?schema = blank&ws_key = MYKEY = keywords&language = 1

with this xml 这个XML

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
   <customer>
      <id_customer>12</id_customer>
      <id_currency>1</id_currency>
      <id_lang>1</id_lang>
      <associations>
         <cart_rows>
            <cart_row>
               <CartRow>
                  <id_product>1</id_product>
                  <id_product_attribute>1</id_product_attribute>
                  <id_address_delivery>10</id_address_delivery>
                  <quantity>1</quantity>
               </CartRow>
            </cart_row>
         </cart_rows>
      </associations>
   </customer>
</prestashop>

I have two issues I would like to fix, 我有两个问题要解决,

First: I'm getting this error: 第一:我收到此错误:

<![CDATA[[SQL Error] Column 'id_product_attribute' cannot be null. From CartCore->setWsCartRows() Query was : INSERT INTO `ps_cart_product`(`id_cart`, `id_product`, `id_product_attribute`, `id_address_delivery`, `quantity`, `date_add`, `id_shop`) VALUES (18, 0, NULL, 0, 0, NOW(), 1)]]>

but the id attribute and product are on the database (I checked on the table products and prorduct_attribute) 但是id属性和product在数据库中(我在表products和prorduct_attribute上进行了检查)

Second: 第二:

I only have the sku is there any way to get the id_product and the id_product_attribute throw the webservice product? 我只有sku,有什么办法让id_product和id_product_attribute抛出Web服务产品吗? or do I have to build a custom module or something to get the productid? 还是我必须构建一个自定义模块或其他东西来获取产品编号?

Thanks a lot for the help! 非常感谢您的帮助!

Your XML es wrong formed. 您的XML格式错误。 Notice that in query error id_product and id_product_attribute values are 0 and NULL, so data you are passing into XML never find correct destination in webservice. 请注意,在查询错误中,id_product和id_product_attribute的值为0和NULL,因此要传递给XML的数据永远不会在Web服务中找到正确的目的地。

If you have SKU you must first get products filtered by reference (or ean13 or UPC or the field that SKU represent in Prestashop). 如果您有SKU,则必须先按参考(或ean13或UPC或SKU在Prestashop中代表的字段)过滤产品。 That way you will have id_product and id_product_attribute yo pass it to webservice in your XML. 这样,您将获得id_product和id_product_attribute并将其通过XML传递到Web服务。

Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM