Created
November 12, 2014 11:40
-
-
Save manelio/5791101c513bf2d5d531 to your computer and use it in GitHub Desktop.
Magento performance: getSortedAttributes caching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Core optimization I: | |
| Test: | |
| url: http://myproject.com.local/ (a catalog page that loads 111 products) | |
| Before: | |
| Total Incl. Wall Time (microsec): 34,340,233 microsecs | |
| Number of Function Calls: 10,098,542 | |
| After: | |
| Total Incl. Wall Time (microsec): 16,672,205 microsecs | |
| Number of Function Calls: 3,944,652 | |
| Code: | |
| # create a copy of Mage_Eav_Model_Entity_Abstract in pool local | |
| install -D web/app/code/core/Mage/Eav/Model/Entity/Abstract.php web/app/code/local/Mage/Eav/Model/Entity/Abstract.php | |
| # add to class attributes: | |
| protected static $_sortedAttributesBySetId = array(); | |
| # rename method getSortedAttributes to _getSortedAttributes | |
| # add method getSortedAttributes: | |
| public function getSortedAttributes($setId = null) | |
| { | |
| if (key_exists($setId, self::$_sortedAttributesBySetId)) { | |
| $sortedAttributes = self::$_sortedAttributesBySetId[ $setId ]; | |
| } | |
| else { | |
| $sortedAttributes = $this->_getSortedAttributes($setId); | |
| self::$_sortedAttributesBySetId[ $setId ] = $sortedAttributes; | |
| } | |
| return $sortedAttributes; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment