I am trying to override class Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector

I tried everything and checked the implementation is correct in di.xml

The method I am trying to override is a protected method processProductItems()

I have no clue what am I doing wrong here. It keeps calling the function from the original Magento_Tax class


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector"

Override class Folio3\TaxCollector\Model\Sales\Total\Quote\CommonTaxCollector.php

class CommonTaxCollector extends \Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Folio3_TaxCollector" setup_version="1.0.0">
            <module name="Magento_Catalog"/>
            <module name="Magento_Checkout"/>
            <module name="Magento_Customer"/>
            <module name="Magento_Directory"/>
            <module name="Magento_User"/>
            <module name="Magento_Tax" />

Can anyone explain to me what am I doing wrong here? I think I have followed all the necessary steps. It keeps calling the original CommonTaxCollector.php class from Magento_Tax module

  • Is there any error that you are facing? Nov 11, 2020 at 11:27
  • Facing No errors at all Nov 11, 2020 at 11:28
  • Can you check changing scope of your di.xml? Where it is sitting currently? Global?
    – mskhan
    Nov 11, 2020 at 11:34
  • Tried with global and frontend both scopes, no luck Nov 11, 2020 at 11:36
  • can you share your overrided function processProductItems Nov 11, 2020 at 12:04

1 Answer 1


This is because you are overriding the wrong class.


The class CommonTaxCollector is not used directly, Magento2 used a Tax class which overrides the CommonTaxCollector class.



namespace Magento\Tax\Model\Sales\Total\Quote;

class Tax extends CommonTaxCollector {



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Tax\Model\Sales\Total\Quote\Tax"

Override class Folio3\TaxCollector\Model\Sales\Total\Quote\Tax.php

class Tax extends \Magento\Tax\Model\Sales\Total\Quote\Tax

It should work fine!

  • That worked! Thanks a lot Nov 11, 2020 at 14:06

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.