0

I have added tax rule in

sales -> manage tax rules

and associate with customer tax class.

Now how can I programatically get this rules or fetch all the rules defined here ?

I tried this

$tax = Mage::getModel('tax/calculation')->getCollection();

            foreach($tax as $rr) {
                 echo $rr->getRuleName();
                 echo $rr->getRuleId();
                 echo '<br>';
            }

but getting blank

1

Try this

$collection = Mage::getModel('tax/calculation_rule')->getCollection();
if($collection->getSize()) {
    $collection->addCustomerTaxClassesToResult()
    ->addProductTaxClassesToResult()
    ->addRatesToResult();
}
if($collection->getSize()) {
    foreach($collection as $rule) {
        print_r($rule);
    }
}
0

If you want to load by id:

$taxRule = Mage::getModel('tax/sales_order_tax')->load($id);

or get all:

$taxRules = Mage::getModel('tax/sales_order_tax')->getCollection();

foreach($taxRules as $taxRule){
    echo $taxRule->getId();
//etc
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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