I am trying to filter product collection by price range:

     ->addAttributeToFilter('price', array( 'lt' => 500 ) )
     ->addAttributeToFilter('price', array( 'gt' => 100 ) )

this works fine however Magento uses price before tax to select the range and I would like to select by price after tax.

Is there a filter property, like 'price_after_tax' that contains this value? If not can somehow the current tax be calculated from the input range values? I could then calculate net price range.

Any other advice would be highly appreciated. Thanks!

  • The only option for me is to deal with this issue programmatically, from module's level. I would rather not change Magento's configuration(product's are already uploaded, other custom modules installed).
  • how to apply filter in magento 2
    – Devidas
    Commented May 21, 2021 at 5:06

3 Answers 3


The price attribute is much like any other - just a value assigned to that product, essentially what you are saying you want to do is filter by value other than what is entered (being price after tax) which you obviously can't do.

What you need to do here is instead alter what the product price represents from being the price without tax, to the price with tax. So under system->configuration->tax->calculation settings change catalog prices from excluding tax which is what it sounds like they are currently to including tax.

Obviously this means having to change the price all of your catalog items to be the price including tax, but if you want to be able to filter by price including tax this is your best, cleanest option.

  • Thanks for your answer Jonathan. That's a good advice but unfortunately not an option for me. I can't change shop settings. The only way for me is to deal with this programmatically, from module's level.
    – Alan
    Commented Nov 18, 2014 at 12:45
  • Well you don't unfortunately really have any other good options available to you, the next best way to do this would be to pass values to addAttributeToFilter() that represent price before tax as the price you enter on the product is the only one stored to the product, the rest are calculated on the fly. A third....highly unworkable solution imo is to add another attribute to each product with the price after tax and filter by that, but then you have to maintain 2 prices for each product - not great. Commented Nov 18, 2014 at 13:10

check out this admin setting may help you. System > Configuration > Sales > Tax > Price Display Settings

The Tax - Price Display Settings determine whether the catalog prices and shipping prices that are displayed in your store include tax.

  • This option is set to 'Including and Excluding Tax' and that's how products' prices are showing in the front end. Unfortunately I can't set it to 'Including Tax' only.
    – Alan
    Commented Nov 18, 2014 at 12:25

I've found the answer:

$calc = Mage::getSingleton('tax/calculation');
$rates = $calc->getRatesForAllProductTaxClasses($calc->getRateRequest());
foreach ($rates as $class=>$rate) {
   $result = $rate;

and then I use $result to calculate net price from visitor's input and use it in the filter. It seems to work pretty fine :).

More details here: How to obtain the rate of VAT in Magento without order object or product

  • Ah right, would have come with a different answer if you said there was user input to work with! Commented Nov 18, 2014 at 13:12
  • Sorry, I will be more accurate next time. Thanks for your input anyway!
    – Alan
    Commented Nov 18, 2014 at 15:23

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.