I want to create a feature in an upgrade script that creates 2 new tax rates in Magento.

I looked at the importPost controller in adminhtml tax rates controller, but there is a lot of work in there. I was hoping for a nice easy way kind of like:

Mage::getModel('tax model')->setData('tax rate data')->save()

Anyone know how to do this?


1 Answer 1


This is how I created a new tax rule in an upgradescript for an Australian shop:

//get the product tax class
$productTaxClass = Mage::getModel('tax/class')
    ->addFieldToFilter('class_name', 'Taxable Goods')

//get the customer tax class
$customerTaxClass = Mage::getModel('tax/class')
    ->addFieldToFilter('class_name', 'Retail Customer')

//create a new australia tax rate/zone
$taxCalculationRate = Mage::getModel('tax/calculation_rate')
        "code"                  => "GST",
        "tax_country_id"        => "AU",
        "tax_region_id"         => "0",
        "zip_is_range"          => "0",
        "tax_postcode"          => "*",
        "rate"                  => "10",

//create a new tax rule
$ruleModel = Mage::getModel('tax/calculation_rule')
        "code"                  => "GST",
        "tax_customer_class"    => array($customerTaxClass->getId()),
        "tax_product_class"     => array($productTaxClass->getId()),
        "tax_rate"              => array($taxCalculationRate->getId()),
        "priority"              => "0",
        "position"              => "0",
  • Curious how well this would work when used in conjunction with a tax lookup service. Do a lookup on customer's tax rate and then programmatically store it in the backend if it doesn't already exist...
    – pspahn
    Aug 8, 2013 at 0:10

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.