本文整理汇总了PHP中GroupReduction::save方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupReduction::save方法的具体用法?PHP GroupReduction::save怎么用?PHP GroupReduction::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupReduction
的用法示例。
在下文中一共展示了GroupReduction::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCategoryReduction
protected function updateCategoryReduction()
{
$category_reduction = Tools::getValue('category_reduction');
Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'group_reduction`
WHERE `id_group` = ' . (int) Tools::getValue('id_group'));
Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'product_group_reduction_cache`
WHERE `id_group` = ' . (int) Tools::getValue('id_group'));
if (is_array($category_reduction) && count($category_reduction)) {
if (!Configuration::getGlobalValue('PS_GROUP_FEATURE_ACTIVE')) {
Configuration::updateGlobalValue('PS_GROUP_FEATURE_ACTIVE', 1);
}
foreach ($category_reduction as $cat => $reduction) {
if (!Validate::isUnsignedId($cat) || !$this->validateDiscount($reduction)) {
$this->errors[] = Tools::displayError('The discount value is incorrect.');
} else {
$category = new Category((int) $cat);
$category->addGroupsIfNoExist((int) Tools::getValue('id_group'));
$group_reduction = new GroupReduction();
$group_reduction->id_group = (int) Tools::getValue('id_group');
$group_reduction->reduction = (double) ($reduction / 100);
$group_reduction->id_category = (int) $cat;
if (!$group_reduction->save()) {
$this->errors[] = Tools::displayError('You cannot save group reductions.');
}
}
}
}
}