// Fix ObjectModel->associateTo()
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8002 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
eb2c483f2f
commit
4de7854629
1 file changed
+6
-4
@@ -252,7 +252,9 @@ abstract class ObjectModelCore
|
|||||||
if (!Shop::isMultishopActivated())
|
if (!Shop::isMultishopActivated())
|
||||||
{
|
{
|
||||||
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'shop')
|
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'shop')
|
||||||
|
{
|
||||||
$result &= $this->associateTo(Context::getContext()->shop->getID(true), 'shop');
|
$result &= $this->associateTo(Context::getContext()->shop->getID(true), 'shop');
|
||||||
|
}
|
||||||
$assos = GroupShop::getAssoTables();
|
$assos = GroupShop::getAssoTables();
|
||||||
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'group_shop')
|
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'group_shop')
|
||||||
$result &= $this->associateTo(Context::getContext()->shop->getGroupID(), 'group_shop');
|
$result &= $this->associateTo(Context::getContext()->shop->getGroupID(), 'group_shop');
|
||||||
@@ -778,10 +780,10 @@ abstract class ObjectModelCore
|
|||||||
* This function associate an item to its context
|
* This function associate an item to its context
|
||||||
*
|
*
|
||||||
* @param int|array $id_shops
|
* @param int|array $id_shops
|
||||||
* @param string $context
|
* @param string $type
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function associateTo($id_shops, $context = 'shop')
|
public function associateTo($id_shops, $type = 'shop')
|
||||||
{
|
{
|
||||||
if (!$this->id)
|
if (!$this->id)
|
||||||
return;
|
return;
|
||||||
@@ -791,12 +793,12 @@ abstract class ObjectModelCore
|
|||||||
|
|
||||||
foreach ($id_shops as $id_shop)
|
foreach ($id_shops as $id_shop)
|
||||||
{
|
{
|
||||||
if (!$this->isAssociatedToShop($id_shop))
|
if (($type == 'shop' && !$this->isAssociatedToShop($id_shop)) || ($type == 'group_shop' && !$this->isAssociatedToGroupShop($id_shop)))
|
||||||
$sql .= '('.(int)$this->id.','.(int)$id_shop.'),';
|
$sql .= '('.(int)$this->id.','.(int)$id_shop.'),';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sql))
|
if (!empty($sql))
|
||||||
return Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.$this->table.'_'.$context.'` (`'.$this->identifier.'`, `id_'.$context.'`) VALUES '.rtrim($sql,','));
|
return Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.$this->table.'_'.$type.'` (`'.$this->identifier.'`, `id_'.$type.'`) VALUES '.rtrim($sql,','));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user