I'm trying to get product price both excluding and including tax in EcomDev_PHPUnit.

I have a fixture based on the one provided in official manual. I've put the following between scope and eav:

  default/catalog/price/scope: 1 # Set price scope to website
  default/tax/calculation/algorithm: UNIT_BASE_CACLULATION
  default/tax/calculation/based_on: origin
  default/tax/calculation/apply_tax_on: 0
  default/tax/calculation/price_includes_tax: 0
  default/tax/calculation/apply_after_discount: 1
  default/tax/defaults/country: DE
  default/tax/defaults/region: 0
  default/tax/defaults/postcode: *
  default/tax/display/type: 2
  default/tax/sales_display/price: 1
    - class_id: 3
      class_name: Retail Customer
      class_type: CUSTOMER
    - tax_calculation_rate_id: 3
      tax_country_id: DE
      tax_region_id: 12
      tax_postcode: *
      code: VAT
      rate: 19
    - tax_calculation_rule_id: 1
      code: Retail Customer-VAT
      priority: 1
      position: 1
      calculate_subtotal: 0
    - tax_calculation_id: 3
      tax_calculation_rule_id: 1
      tax_calculation_rate_id: 3
      customer_tax_class_id: 3
      product_tax_class_id: 3
    - customer_group_id: 1
      customer_group_code: General
      tax_class_id: 3

The failing part of the test is:

$finalPriceInclTax = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true);
$finalPriceExclTax = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), false);

// Check that prices including and excluding tax are different

In both $finalPriceInclTax and $finalPriceExclTax I'm getting the price excluding tax.

Could you please help me with this fixture? I'm obviously missing something here.


  • I would very much prefer using a fixture to setting up tax in the test itself
  • I need to get both prices on the catalog level (not checkout)

1 Answer 1


The function getPrice() look like this

public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null,
                         $ctc = null, $store = null, $priceIncludesTax = null, $roundPrice = true)

So try

$finalPriceInclTax = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true, null, null, null, null, false);

To get price including tax

  • Thanks for your answer @arshad, but passing default values for arguments doesn't change anything. Setting $roundPrice to either true or false does change function's output but still I get price excluding tax in both $finalPriceInclTax and $finalPriceExclTax. Apr 8, 2015 at 10:33

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.