// Fix ObjectModel::updateMultishopTable() for Combination
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14691 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+11
-13
@@ -1129,12 +1129,13 @@ abstract class ObjectModelCore
|
|||||||
* @param string $classname
|
* @param string $classname
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @param string $where
|
* @param string $where
|
||||||
|
* @param string $specific_where Only executed for common table
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function updateMultishopTable($classname, $data, $where)
|
public static function updateMultishopTable($classname, $data, $where, $specific_where = '')
|
||||||
{
|
{
|
||||||
$def = ObjectModel::getDefinition($classname);
|
$def = ObjectModel::getDefinition($classname);
|
||||||
$common_data = $shop_data = array();
|
$update_data = array();
|
||||||
$is_default_shop = Context::getContext()->shop->id == Configuration::get('PS_SHOP_DEFAULT');
|
$is_default_shop = Context::getContext()->shop->id == Configuration::get('PS_SHOP_DEFAULT');
|
||||||
foreach ($data as $field => $value)
|
foreach ($data as $field => $value)
|
||||||
{
|
{
|
||||||
@@ -1144,21 +1145,18 @@ abstract class ObjectModelCore
|
|||||||
if (!empty($def['fields'][$field]['shop']))
|
if (!empty($def['fields'][$field]['shop']))
|
||||||
{
|
{
|
||||||
if ($is_default_shop)
|
if ($is_default_shop)
|
||||||
$common_data[$field] = $value;
|
$update_data[] = "a.$field = '$value'";
|
||||||
$shop_data[$field] = $value;
|
$update_data[] = "{$def['table']}_shop.$field = '$value'";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$common_data[$field] = $value;
|
$update_data[] = "a.$field = '$value'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = true;
|
$sql = 'UPDATE '._DB_PREFIX_.$def['table'].' a
|
||||||
if ($common_data)
|
'.Shop::addSqlAssociation($def['table'], 'a').'
|
||||||
$result &= Db::getInstance()->update($def['table'], $common_data, $where);
|
SET '.implode(', ', $update_data).'
|
||||||
|
WHERE '.$where;
|
||||||
if ($shop_data)
|
return Db::getInstance()->execute($sql);
|
||||||
$result &= Db::getInstance()->update($def['table'].'_shop', $shop_data, $where.' AND id_shop = '.(int)Context::getContext()->shop->id);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user