This module takes a library for topological sorting and fixes the broken algorithm to sort lots of stuff which has `before` and `after` dependencies, like totals in quote, order and creditmemo.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/app/code/local/Mage/Sales/Model/Config
.gitignore
LICENSE
README.md
composer.json
modman

README.md

#Topological Sorting of Total Models In Magento we have the problem, that Mage_Sales_Model_Config_Ordered should sort a bunch of items topological, but unfortunately it doesn't.

I encountered the problem with wrongly sorted totals a few times, but now it was enough. I wrote a blog article about it. Thanks to @Daniel_Sloof, he pointed me to more informations from @VinaiKopp. I then found a question on Stackoverflow from @s3lf.

After reading all this I decided to implement a module which fixes this. Thanks to Dan Mossop there existed already an algorithm. But it was untested, so I decided to write a few tests for it and then write a Magento module. But we are all lazy and why write tests, if already someone else did. So lets take the algorithm from Marc J. Schmidt.

Unfortunately is the bug in an abstract class, therefore we have to overwrite a core file in app/code/local

Installation

##composer Add the following to your composer.json

{
 "require": {
     "marcj/topsort": "~0.1"
 }
}

The problem is, that magento doesn't load libraries, that use namespaces. But as always, there is a stackoverflow question, how to add the composer autoloader. I personally just added require 'vendor/autoload.php'; to the first line of index.php. Not best practice, but our index.php is already edited, so it doesn't matter.

What this module is doing

This module takes a library for topological sorting and fixes the broken algorithm to sort lots of stuff which has before and after dependencies, like totals in quote, order and creditmemo.

#License My work is under BSD 3-clause. But be careful, I only changed the \Mage_Sales_Model_Config_Ordered::_getSortedCollectorCodes implementation and added the topological sorting to the class. The rest us copied from Magento version 1.9.1