ivanferrer Posted May 17, 2016 Share Posted May 17, 2016 (edited) There is an error in Prestashop, which is causing loss of data in order_detail table, what can I do to fix the problem? Making a query by list the cart, I came across some items with null: Query Prestashop: SELECT SQL_NO_CACHE * FROM `ps_order_detail` od LEFT JOIN `ps_product` p ON (p.id_product = od.product_id) LEFT JOIN `ps_product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop) WHERE od.`id_order` = 123; My Query: set sql_mode=''; SELECT SQL_NO_CACHE detail.id_order_detail, ord.id_order, inv.id_order_invoice, IF(warh.id_warehouse is NULL,0,warh.id_warehouse) as id_warehouse, ord.id_shop, p.id_product AS product_id, IF(stock.id_product_attribute is NULL,0,stock.id_product_attribute) AS product_attribute_id, plg.name AS product_name, SUM(p.id_product) AS product_quantity, IF(stock.quantity is NULL, 0, stock.quantity) AS product_quantity_in_stock, detail.product_quantity_refunded, detail.product_quantity_return, detail.product_quantity_reinjected, detail.reduction_percent, detail.reduction_amount, detail.reduction_amount_tax_incl, detail.reduction_amount_tax_excl, detail.group_reduction, detail.product_quantity_discount, detail.product_ean13, detail.product_reference, detail.product_supplier_reference, detail.product_weight, detail.id_tax_rules_group, detail.tax_computation_method, detail.tax_name, detail.reduction_amount, detail.reduction_amount_tax_incl, detail.reduction_amount_tax_excl, detail.group_reduction, detail.product_quantity_discount, detail.product_ean13, detail.product_reference, detail.product_supplier_reference, detail.product_weight, detail.id_tax_rules_group, detail.tax_computation_method, detail.tax_name, ps.ecotax, detail.ecotax_tax_rate, detail.discount_quantity_applied, detail.download_hash, detail.download_nb, detail.download_deadline, detail.total_price_tax_excl, detail.unit_price_tax_incl, detail.unit_price_tax_excl, detail.total_shipping_price_tax_incl, detail.total_shipping_price_tax_excl, detail.purchase_supplier_price, detail.original_product_price, detail.product_price FROM `ps_orders` ord INNER JOIN `ps_cart` c ON (c.id_cart = ord.id_cart) INNER JOIN `ps_cart_product` cprod ON (c.id_cart = cprod.id_cart) LEFT JOIN `ps_order_invoice` inv ON (ord.id_order = inv.id_order) LEFT JOIN `ps_product` p ON (p.id_product = cprod.id_product) LEFT JOIN `ps_product_lang` plg ON (plg.id_product = cprod.id_product AND plg.id_lang = ord.id_shop) LEFT JOIN `ps_product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = ord.id_shop) LEFT JOIN `ps_stock_available` stock ON (stock.id_product = p.id_product) LEFT JOIN `ps_warehouse_product_location` warh ON (warh.id_product = p.id_product) LEFT JOIN `ps_order_detail` detail ON (detail.product_id = p.id_product AND ord.`id_order`=detail.id_order) WHERE ord.`id_order` = 123 group by p.id_product; Edited May 17, 2016 by ivanferrer (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted May 18, 2016 Share Posted May 18, 2016 I don't see any NULL values. This issue can appear only in your database. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now