conflicting two magento extension

2019-02-20 15:33发布

问题:

I have two same extension but both are using for a different-different purpose.

Extension A Config.xml

<config>
<modules>
    <Mageworks_Fee>
        <version>0.1.5</version>
    </Mageworks_Fee>
</modules>
<global>
    <sales>
        <quote>
            <totals>
                <fee>
                    <class>fee/sales_quote_address_total_fee</class>
                    <renderer>fee/checkout_totals_fee</renderer>
                    <admin_renderer>fee/adminhtml_sales_order_create_totals_fee</admin_renderer>
                </fee>
            </totals>
        </quote>
        <order_invoice>
            <totals>
                <fee>
                    <class>fee/sales_order_total_invoice_fee</class>
                </fee>
            </totals>
        </order_invoice>
        <order_creditmemo>
            <totals>
                <fee>
                    <class>fee/sales_order_total_creditmemo_fee</class>
                </fee>
            </totals>
        </order_creditmemo>
    </sales>
   </global>
 </config> 

Extension B Config.xml

 <config>
<modules>
    <Mageworks_Insurance>
        <version>0.1.5</version>
    </Mageworks_Insurance>
</modules>
<global>
    <sales>
        <quote>
            <totals>
                <insurance>
                    <class>insurance/sales_quote_address_total_insurance</class>
        <before>fee</before>
                    <renderer>insurance/checkout_totals_insurance</renderer>
                    <admin_renderer>insurance/adminhtml_sales_order_create_totals_insurance</admin_renderer>
                </insurance>
            </totals>
        </quote>
        <order_invoice>
            <totals>
                <insurance>
                    <class>insurance/sales_order_total_invoice_insurance</class>
                </insurance>
            </totals>
        </order_invoice>
        <order_creditmemo>
            <totals>
                <insurance>
                    <class>insurance/sales_order_total_creditmemo_insurance</class>
                </insurance>
            </totals>
        </order_creditmemo>
    </sales> 
   </global>
 </config>   

Both are conflicting in total price , Please help how can i solve this issue.

回答1:

This is the same issue which i faced ,Currently you are adding before tag only in one extension so remove this line.

<before>fee</before>

you have to set the after and before tag in both of the extension.

In Extension A Config.xml file use this

<after>subtotal,discount,shipping</after> 
<before>tax,grand_total</before> 

and in your Extension B Config.xml file use this

<after>fee</after> 
<before>tax,grand_total</before> 

Hope this will help yours



回答2:

The sort algorithm used by Magento is not stable and can lead to wrong results. You can use this patch: https://stackoverflow.com/a/11954867/288568