Jump to content

Edit History

ricardomyra

ricardomyra

I had the same problem and the error was in a change I had made to the order.php class file.

I changed this original piece of code:

public function getProductsDetail()
     {
         return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id)
LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop)
WHERE od.`id_order` = '.(int)$this->id);
     }

I changed it to:


public function getProductsDetail()
     {
         return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
         SELECT *
         FROM `'._DB_PREFIX_.'order_detail` od
         LEFT JOIN '._DB_PREFIX_.'product p ON ( p.id_product = od.product_id)
         LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product)
         LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
         WHERE od.`id_order` = '.(int)($this->id));
     }

And the correction I made was to include this in the code:


public function getProductsDetail()
     {
         return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
         SELECT *
         FROM `'._DB_PREFIX_.'order_detail` od
         LEFT JOIN '._DB_PREFIX_.'product p ON ( p.id_product = od.product_id)
         LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product and pl.id_lang=2)
         LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
         WHERE od.`id_order` = '.(int)($this->id));
     }

This query that contained the error was returning more than one record and this caused the problem, I hope this tip can help other people.

In my case 2 records were returned and the quantities returned to stock were multiplied by 2 when an order was cancelled.

I use version 1.6.1.4

PS: I made this change to be able to get the product image link and show the product photo on the screen where the customer has the order details.

ricardomyra

ricardomyra

I had the same problem and the error was in a change I had made to the order.php class file.

I changed this original piece of code:

public function getProductsDetail()
     {
         return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id)
LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop)
WHERE od.`id_order` = '.(int)$this->id);
     }

I changed it to:


public function getProductsDetail()
     {
         return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
         SELECT *
         FROM `'._DB_PREFIX_.'order_detail` od
         LEFT JOIN '._DB_PREFIX_.'product p ON ( p.id_product = od.product_id)
         LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product)
         LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
         WHERE od.`id_order` = '.(int)($this->id));
     }

And the correction I made was to include this in the code:


public function getProductsDetail()
     {
         return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
         SELECT *
         FROM `'._DB_PREFIX_.'order_detail` od
         LEFT JOIN '._DB_PREFIX_.'product p ON ( p.id_product = od.product_id)
         LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product and pl.id_lang=2)
         LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
         WHERE od.`id_order` = '.(int)($this->id));
     }

This query that contained the error was returning more than one record and this caused the problem, I hope this tip can help other people.

In my case 2 records were returned and the quantities returned to stock were multiplied by 2 when an order was cancelled.

 

×
×
  • Create New...