[-] BO: Auto-select the tax rules group most used on product creation
This commit is contained in:
@@ -5215,6 +5215,23 @@ class ProductCore extends ObjectModel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getIdTaxRulesGroupMostUsed()
|
||||||
|
{
|
||||||
|
return Db::getInstance()->getValue('
|
||||||
|
SELECT id_tax_rules_group
|
||||||
|
FROM (
|
||||||
|
SELECT COUNT(*) n, product_shop.id_tax_rules_group
|
||||||
|
FROM '._DB_PREFIX_.'product p
|
||||||
|
'.Shop::addSqlAssociation('product', 'p').'
|
||||||
|
JOIN '._DB_PREFIX_.'tax_rules_group trg ON (product_shop.id_tax_rules_group = trg.id_tax_rules_group)
|
||||||
|
WHERE trg.active = 1
|
||||||
|
GROUP BY product_shop.id_tax_rules_group
|
||||||
|
ORDER BY n DESC
|
||||||
|
LIMIT 1
|
||||||
|
) most_used'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For a given ean13 reference, returns the corresponding id
|
* For a given ean13 reference, returns the corresponding id
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2876,13 +2876,15 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
'countries' => $countries,
|
'countries' => $countries,
|
||||||
'groups' => $groups,
|
'groups' => $groups,
|
||||||
'combinations' => $combinations,
|
'combinations' => $combinations,
|
||||||
'product' => $product,
|
|
||||||
'multi_shop' => Shop::isFeatureActive(),
|
'multi_shop' => Shop::isFeatureActive(),
|
||||||
'link' => new Link()
|
'link' => new Link()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$this->displayWarning($this->l('You must save this product before adding specific pricing'));
|
$this->displayWarning($this->l('You must save this product before adding specific pricing'));
|
||||||
|
$product->id_tax_rules_group = (int)Product::getIdTaxRulesGroupMostUsed();
|
||||||
|
}
|
||||||
|
|
||||||
// prices part
|
// prices part
|
||||||
$data->assign(array(
|
$data->assign(array(
|
||||||
|
|||||||
Reference in New Issue
Block a user