diff --git a/classes/order/Order.php b/classes/order/Order.php
index 3402b6dcd..86960bad9 100644
--- a/classes/order/Order.php
+++ b/classes/order/Order.php
@@ -488,9 +488,8 @@ class OrderCore extends ObjectModel
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
- '.Shop::addSqlAssociation('product', 'p').'
+ 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));
}
diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php
index def6feec5..d3ada6e0a 100644
--- a/classes/order/OrderDetail.php
+++ b/classes/order/OrderDetail.php
@@ -39,6 +39,9 @@ class OrderDetailCore extends ObjectModel
/** @var integer */
public $product_id;
+ /** @var integer */
+ public $id_shop;
+
/** @var integer */
public $product_attribute_id;
@@ -160,6 +163,7 @@ class OrderDetailCore extends ObjectModel
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_order_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
+ 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'product_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'product_attribute_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'product_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
@@ -546,7 +550,10 @@ class OrderDetailCore extends ObjectModel
// Set order invoice id
$this->id_order_invoice = (int)$id_order_invoice;
-
+
+ // Set shop id
+ $this->id_shop = (int)$product['id_shop'];
+
// Add new entry to the table
$this->save();
diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php
index d9fa8d74d..c8dbe4511 100644
--- a/classes/order/OrderInvoice.php
+++ b/classes/order/OrderInvoice.php
@@ -119,7 +119,7 @@ class OrderInvoiceCore extends ObjectModel
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'product` p
ON p.id_product = od.product_id
- '.Shop::addSqlAssociation('product', 'p').'
+ 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_order.'
AND od.`id_order_invoice` = '.(int)$this->id);
}
diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql
index 5fcaf6f7a..336a5a2f0 100644
--- a/install-dev/data/db_structure.sql
+++ b/install-dev/data/db_structure.sql
@@ -1119,6 +1119,7 @@ CREATE TABLE `PREFIX_order_detail` (
`id_order` int(10) unsigned NOT NULL,
`id_order_invoice` int(11) default NULL,
`id_warehouse` int(10) unsigned DEFAULT 0,
+ `id_shop` int(11) unsigned NOT NULL,
`product_id` int(10) unsigned NOT NULL,
`product_attribute_id` int(10) unsigned default NULL,
`product_name` varchar(255) NOT NULL,
diff --git a/install-dev/fixtures/apple/data/order_detail.xml b/install-dev/fixtures/apple/data/order_detail.xml
index f838beeee..d375eb0de 100644
--- a/install-dev/fixtures/apple/data/order_detail.xml
+++ b/install-dev/fixtures/apple/data/order_detail.xml
@@ -4,6 +4,7 @@
+
@@ -43,11 +44,11 @@
-
+
iPod touch - Capacité: 32Go
-
+
Écouteurs à isolation sonore Shure SE210
diff --git a/install-dev/upgrade/sql/1.5.0.16.sql b/install-dev/upgrade/sql/1.5.0.16.sql
new file mode 100644
index 000000000..41cd25e36
--- /dev/null
+++ b/install-dev/upgrade/sql/1.5.0.16.sql
@@ -0,0 +1,5 @@
+SET NAMES 'utf8';
+
+ALTER TABLE `PREFIX_order_detail` ADD `id_shop` INT(11) UNSIGNED NOT NULL AFTER `id_warehouse`, ADD INDEX (`id_shop`);
+
+UPDATE `PREFIX_order_detail` od SET `id_shop`=(SELECT `id_shop` FROM `PREFIX_orders` WHERE `id_order`=od.`id_order`);