Following a previous question as a simple guide:

How to programatically create tax rates

Instead of creating a tax rule programmatically, I would like to modify an existing rule, specifically the 'tax_rule' array (which should contain a list of tax rate IDs that are valid for this rule.

These rates can be found by using:

$ruleModel = Mage::getModel('tax/calculation_rule')->load($id);

This should return an array of tax rate IDs that apply to this rule.

Using $ruleModel->setRates($array)->save() just messes up this rule, removing other values that were previously saved (rule name, priority, etc).

How can I simply load an existing rate model and update the 'tax_rate' field to include an additional tax rate? If the existing array is array(5,7,9) I would like to update the array to include a new value as well, ie array(5,7,9,15).

1 Answer 1


Unless someone else comes across this question and knows a proper answer, it seems that Magento does not store the rates inside tax/calculation_rule but instead in tax/calculation table. When a rule's rates are updated in the backend, Magento will natively drop all the rows in the table associated with the rule and create new ones. This is evidenced by the fact that each row's ID value is auto-incremented, even if none of the values of that row changed.

My goal was to have new rates created dynamically and then added to an existing rule. I have opted to just create a new rule dynamically also. It's going to create more overhead in the DB this way (each tax rate has its own tax rule), but I don't see a clean way around that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.