Saikios Saikios - 4 months ago 36
PHP Question

Adding products in cart by sku on prestashop

I'm using prestashop webservice for an integration,

I'm sending throw POST

with this xml

<prestashop xmlns:xlink="">

I have two issues I would like to fix,

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)


I only have the sku is there any way to get the id_product and the id_product_attribute throw the webservice product? 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. 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.

If you have SKU you must first get products filtered by reference (or ean13 or UPC or the field that SKU represent in Prestashop). That way you will have id_product and id_product_attribute yo pass it to webservice in your XML.

Good luck.