[-] BO: Invoices and products order detail are now not empty after deleting a product
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16741 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<field name="id_order" relation="orders"/>
|
||||
<field name="id_order_invoice"/>
|
||||
<field name="id_warehouse"/>
|
||||
<field name="id_shop"/>
|
||||
<field name="product_id" relation="product"/>
|
||||
<field name="product_attribute_id" relation="product_attribute"/>
|
||||
<field name="product_name"/>
|
||||
@@ -43,11 +44,11 @@
|
||||
<field name="original_product_price"/>
|
||||
</fields>
|
||||
<entities>
|
||||
<order_detail id="order_detail_1" id_order="1" id_order_invoice="" id_warehouse="0" product_id="iPod_touch" product_attribute_id="product_attribute_23" product_quantity="1" product_quantity_in_stock="0" product_quantity_refunded="0" product_quantity_return="0" product_quantity_reinjected="0" product_price="392.140500" reduction_percent="0.00" reduction_amount="0.000000" reduction_amount_tax_incl="0.000000" reduction_amount_tax_excl="0.000000" group_reduction="0.00" product_quantity_discount="0.000000" product_ean13="" product_upc="" product_reference="" product_supplier_reference="" product_weight="0" tax_computation_method="0" tax_name="" tax_rate="0.000" ecotax="0.000000" ecotax_tax_rate="0.000" discount_quantity_applied="0" download_nb="0" download_deadline="0000-00-00 00:00:00" total_price_tax_incl="469.000000" total_price_tax_excl="392.140000" unit_price_tax_incl="469.000000" unit_price_tax_excl="392.140468" total_shipping_price_tax_incl="0.000000" total_shipping_price_tax_excl="0.000000" purchase_supplier_price="0.000000" original_product_price="0.000000">
|
||||
<order_detail id="order_detail_1" id_order="1" id_shop="1" id_order_invoice="" id_warehouse="0" product_id="iPod_touch" product_attribute_id="product_attribute_23" product_quantity="1" product_quantity_in_stock="0" product_quantity_refunded="0" product_quantity_return="0" product_quantity_reinjected="0" product_price="392.140500" reduction_percent="0.00" reduction_amount="0.000000" reduction_amount_tax_incl="0.000000" reduction_amount_tax_excl="0.000000" group_reduction="0.00" product_quantity_discount="0.000000" product_ean13="" product_upc="" product_reference="" product_supplier_reference="" product_weight="0" tax_computation_method="0" tax_name="" tax_rate="0.000" ecotax="0.000000" ecotax_tax_rate="0.000" discount_quantity_applied="0" download_nb="0" download_deadline="0000-00-00 00:00:00" total_price_tax_incl="469.000000" total_price_tax_excl="392.140000" unit_price_tax_incl="469.000000" unit_price_tax_excl="392.140468" total_shipping_price_tax_incl="0.000000" total_shipping_price_tax_excl="0.000000" purchase_supplier_price="0.000000" original_product_price="0.000000">
|
||||
<product_name>iPod touch - Capacité: 32Go</product_name>
|
||||
<download_hash/>
|
||||
</order_detail>
|
||||
<order_detail id="order_detail_2" id_order="1" id_order_invoice="" id_warehouse="0" product_id="Shure_SE210_Sound-Isolating_Earphones_for_iPod_and_iPhone" product_attribute_id="" product_quantity="1" product_quantity_in_stock="0" product_quantity_refunded="0" product_quantity_return="0" product_quantity_reinjected="0" product_price="124.581900" reduction_percent="0.00" reduction_amount="0.000000" reduction_amount_tax_incl="0.000000" reduction_amount_tax_excl="0.000000" group_reduction="0.00" product_quantity_discount="0.000000" product_ean13="" product_upc="" product_reference="" product_supplier_reference="" product_weight="0" tax_computation_method="0" tax_name="" tax_rate="0.000" ecotax="0.000000" ecotax_tax_rate="0.000" discount_quantity_applied="0" download_nb="0" download_deadline="0000-00-00 00:00:00" total_price_tax_incl="149.000000" total_price_tax_excl="124.580000" unit_price_tax_incl="149.000000" unit_price_tax_excl="124.581940" total_shipping_price_tax_incl="0.000000" total_shipping_price_tax_excl="0.000000" purchase_supplier_price="0.000000" original_product_price="0.000000">
|
||||
<order_detail id="order_detail_2" id_order="1" id_shop="1" id_order_invoice="" id_warehouse="0" product_id="Shure_SE210_Sound-Isolating_Earphones_for_iPod_and_iPhone" product_attribute_id="" product_quantity="1" product_quantity_in_stock="0" product_quantity_refunded="0" product_quantity_return="0" product_quantity_reinjected="0" product_price="124.581900" reduction_percent="0.00" reduction_amount="0.000000" reduction_amount_tax_incl="0.000000" reduction_amount_tax_excl="0.000000" group_reduction="0.00" product_quantity_discount="0.000000" product_ean13="" product_upc="" product_reference="" product_supplier_reference="" product_weight="0" tax_computation_method="0" tax_name="" tax_rate="0.000" ecotax="0.000000" ecotax_tax_rate="0.000" discount_quantity_applied="0" download_nb="0" download_deadline="0000-00-00 00:00:00" total_price_tax_incl="149.000000" total_price_tax_excl="124.580000" unit_price_tax_incl="149.000000" unit_price_tax_excl="124.581940" total_shipping_price_tax_incl="0.000000" total_shipping_price_tax_excl="0.000000" purchase_supplier_price="0.000000" original_product_price="0.000000">
|
||||
<product_name>Écouteurs à isolation sonore Shure SE210</product_name>
|
||||
<download_hash/>
|
||||
</order_detail>
|
||||
|
||||
@@ -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`);
|
||||
Reference in New Issue
Block a user