From 14c20002e463d40ce0412432f874ae59f45fa527 Mon Sep 17 00:00:00 2001 From: rMalie Date: Tue, 17 Apr 2012 15:45:47 +0000 Subject: [PATCH] // Fix ObjectModel::updateMultishopTable() for Combination git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14691 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/ObjectModel.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 24734a439..4f8963fec 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -1129,12 +1129,13 @@ abstract class ObjectModelCore * @param string $classname * @param array $data * @param string $where + * @param string $specific_where Only executed for common table * @return bool */ - public static function updateMultishopTable($classname, $data, $where) + public static function updateMultishopTable($classname, $data, $where, $specific_where = '') { $def = ObjectModel::getDefinition($classname); - $common_data = $shop_data = array(); + $update_data = array(); $is_default_shop = Context::getContext()->shop->id == Configuration::get('PS_SHOP_DEFAULT'); foreach ($data as $field => $value) { @@ -1144,21 +1145,18 @@ abstract class ObjectModelCore if (!empty($def['fields'][$field]['shop'])) { if ($is_default_shop) - $common_data[$field] = $value; - $shop_data[$field] = $value; + $update_data[] = "a.$field = '$value'"; + $update_data[] = "{$def['table']}_shop.$field = '$value'"; } else - $common_data[$field] = $value; + $update_data[] = "a.$field = '$value'"; } - $result = true; - if ($common_data) - $result &= Db::getInstance()->update($def['table'], $common_data, $where); - - if ($shop_data) - $result &= Db::getInstance()->update($def['table'].'_shop', $shop_data, $where.' AND id_shop = '.(int)Context::getContext()->shop->id); - - return $result; + $sql = 'UPDATE '._DB_PREFIX_.$def['table'].' a + '.Shop::addSqlAssociation($def['table'], 'a').' + SET '.implode(', ', $update_data).' + WHERE '.$where; + return Db::getInstance()->execute($sql); } /**