// Normalize some classes
This commit is contained in:
@@ -80,14 +80,25 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
{
|
||||
if (!is_array($conditions))
|
||||
return;
|
||||
if (!Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'specific_price_rule_condition_group` (`id_specific_price_rule_condition_group`, `id_specific_price_rule`)
|
||||
VALUES(\'\', '.(int)$this->id.')'))
|
||||
|
||||
$result = Db::getInstance()->autoExecute(_DB_PREFIX_.'specific_price_rule_condition_group', array(
|
||||
'id_specific_price_rule_condition_group' => '',
|
||||
'id_specific_price_rule' => (int)$this->id
|
||||
), 'INSERT');
|
||||
if (!$result)
|
||||
return false;
|
||||
$id_specific_price_rule_condition_group = (int)Db::getInstance()->Insert_ID();
|
||||
foreach ($conditions as $condition)
|
||||
if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'specific_price_rule_condition (id_specific_price_rule_condition, id_specific_price_rule_condition_group, type, value)
|
||||
VALUES(\'\', '.(int)$id_specific_price_rule_condition_group.', \''.pSQL($condition['type']).'\', \''.pSQL($condition['value']).'\')'))
|
||||
{
|
||||
$result = Db::getInstance()->autoExecute(_DB_PREFIX_.'specific_price_rule_condition', array(
|
||||
'id_specific_price_rule_condition' => '',
|
||||
'id_specific_price_rule_condition_group' => (int)$id_specific_price_rule_condition_group,
|
||||
'type' => $condition['type'],
|
||||
'value' => $condition['value'],
|
||||
), 'INSERT');
|
||||
if (!$result)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -113,14 +124,18 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
|
||||
public function getConditions()
|
||||
{
|
||||
$conditions = Db::getInstance()->executeS('SELECT sprd.*
|
||||
FROM '._DB_PREFIX_.'specific_price_rule_condition_group sprdg
|
||||
LEFT JOIN '._DB_PREFIX_.'specific_price_rule_condition sprd ON (sprd.id_specific_price_rule_condition_group = sprdg.id_specific_price_rule_condition_group)
|
||||
WHERE sprdg.id_specific_price_rule='.(int)$this->id);
|
||||
$conditions = Db::getInstance()->executeS('
|
||||
SELECT g.*
|
||||
FROM '._DB_PREFIX_.'specific_price_rule_condition_group g
|
||||
LEFT JOIN '._DB_PREFIX_.'specific_price_rule_condition c
|
||||
ON (c.id_specific_price_rule_condition_group = g.id_specific_price_rule_condition_group)
|
||||
WHERE g.id_specific_price_rule='.(int)$this->id
|
||||
);
|
||||
|
||||
$conditions_group = array();
|
||||
if ($conditions)
|
||||
{
|
||||
foreach ($conditions AS &$condition)
|
||||
foreach ($conditions as &$condition)
|
||||
{
|
||||
if ($condition['type'] == 'attribute')
|
||||
$condition['id_attribute_group'] = Db::getInstance()->getValue('SELECT id_attribute_group
|
||||
@@ -225,8 +240,8 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
$specific_price->id_group = (int)$rule->id_group;
|
||||
$specific_price->from_quantity = (int)$rule->from_quantity;
|
||||
$specific_price->price = (int)$rule->price;
|
||||
$specific_price->reduction_type = pSQL($rule->reduction_type);
|
||||
$specific_price->reduction = ($rule->reduction_type == 'percentage' ? (float)($rule->reduction / 100) : (float)$rule->reduction);
|
||||
$specific_price->reduction_type = $rule->reduction_type;
|
||||
$specific_price->reduction = ($rule->reduction_type == 'percentage' ? $rule->reduction / 100 : (float)$rule->reduction);
|
||||
$specific_price->from = $rule->from;
|
||||
$specific_price->to = $rule->to;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user