// Refacto of tax_rules_groups_shop
This commit is contained in:
+12
-12
@@ -941,19 +941,15 @@ class CarrierCore extends ObjectModel
|
|||||||
return Cache::retrieve((int)$id_carrier.'_'.(int)$context->shop->id);
|
return Cache::retrieve((int)$id_carrier.'_'.(int)$context->shop->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteTaxRulesGroup(array $shops = null)
|
||||||
public function deleteTaxRulesGroup($shops = false)
|
|
||||||
{
|
{
|
||||||
if (!$shops)
|
if (!$shops)
|
||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
|
|
||||||
$shop = ' AND `id_shop` IN (';
|
$where = 'id_carrier = '.(int)$this->id;
|
||||||
|
if ($shops)
|
||||||
foreach ($shops as $id_shop)
|
$where .= ' AND id_shop IN('.implode(', ', array_map('intval', $shops)).')';
|
||||||
$shop .= (int)$id_shop.',';
|
return Db::getInstance()->delete('carrier_tax_rules_group_shop', $where);
|
||||||
$shop = rtrim($shop, ',').')';
|
|
||||||
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_tax_rules_group_shop
|
|
||||||
WHERE id_carrier='.(int)$this->id.$shop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
|
public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
|
||||||
@@ -968,11 +964,15 @@ class CarrierCore extends ObjectModel
|
|||||||
|
|
||||||
$this->deleteTaxRulesGroup($shops);
|
$this->deleteTaxRulesGroup($shops);
|
||||||
|
|
||||||
$values = '';
|
$values = array();
|
||||||
foreach ($shops as $id_shop)
|
foreach ($shops as $id_shop)
|
||||||
$values .= '('.(int)$this->id.','.(int)$id_tax_rules_group.','.(int)$id_shop.'),';
|
$values[] = array(
|
||||||
|
'id_carrier' => (int)$this->id,
|
||||||
|
'id_tax_rules_group' => (int)$id_tax_rules_group,
|
||||||
|
'id_shop' => (int)$id_shop,
|
||||||
|
);
|
||||||
|
|
||||||
return Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'carrier_tax_rules_group_shop (`id_carrier`, `id_tax_rules_group`, `id_shop`) VALUES '.rtrim($values, ','));
|
return Db::getInstance()->insert('carrier_tax_rules_group_shop', $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+12
-12
@@ -4116,19 +4116,15 @@ class ProductCore extends ObjectModel
|
|||||||
FROM '._DB_PREFIX_.'product_tax_rules_group_shop WHERE `id_product`='.(int)$id_old_product.')');
|
FROM '._DB_PREFIX_.'product_tax_rules_group_shop WHERE `id_product`='.(int)$id_old_product.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteTaxRulesGroup($shops = false)
|
public function deleteTaxRulesGroup(array $shops = null)
|
||||||
{
|
{
|
||||||
if (!$shops)
|
if (!$shops)
|
||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
|
|
||||||
$shop = ' AND `id_shop` IN (';
|
$where = 'id_product = '.(int)$this->id;
|
||||||
|
if ($shops)
|
||||||
foreach ($shops as $id_shop)
|
$where .= ' AND id_shop IN('.implode(', ', array_map('intval', $shops)).')';
|
||||||
$shop .= (int)$id_shop.',';
|
return Db::getInstance()->delete('product_tax_rules_group_shop', $where);
|
||||||
$shop = rtrim($shop, ',').')';
|
|
||||||
|
|
||||||
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'product_tax_rules_group_shop
|
|
||||||
WHERE id_product='.(int)$this->id.$shop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
|
public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
|
||||||
@@ -4143,11 +4139,15 @@ class ProductCore extends ObjectModel
|
|||||||
|
|
||||||
$this->deleteTaxRulesGroup($shops);
|
$this->deleteTaxRulesGroup($shops);
|
||||||
|
|
||||||
$values = '';
|
$values = array();
|
||||||
foreach ($shops as $id_shop)
|
foreach ($shops as $id_shop)
|
||||||
$values .= '('.(int)$this->id.','.(int)$id_tax_rules_group.','.(int)$id_shop.'),';
|
$values[] = array(
|
||||||
|
'id_product' => (int)$this->id,
|
||||||
|
'id_tax_rules_group' => (int)$id_tax_rules_group,
|
||||||
|
'id_shop' => (int)$id_shop,
|
||||||
|
);
|
||||||
|
|
||||||
return Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'product_tax_rules_group_shop (`id_product`, `id_tax_rules_group`, `id_shop`) VALUES '.rtrim($values, ','));
|
return Db::getInstance()->insert('product_tax_rules_group_shop', $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIdTaxRulesGroup(Context $context = null)
|
public function getIdTaxRulesGroup(Context $context = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user