SlideShare uma empresa Scribd logo
1 de 45
Fixing Magento Core for Better Performance
Ivan Chepurnyi
Co Owner / Trainer
EcomDev BV
Ivan Chepurnyi
About me
Meet Magento
• I am Ukrainian
• Technical Consultant, Co-owner at EcomDev B.V.
• Was one of the first five developers in original Magento core team
• Providing trainings and coaching Magento Developers in Europe
• Main areas of my expertise:
– System Architecture
– Performance Optimization
– Test Driven Development
– Complex Customizations
Ivan Chepurnyi
Regular Store Bottlenecks
Meet Magento
• Overall Problems
• Category Pages
• Product Pages
• Checkout Pages
Ivan Chepurnyi Meet Magento
Overall Problems
Ivan Chepurnyi
Problem #1
Meet Magento
Non optimized layout handles usage
Magento adds on every category and product page a layout
handle with its entity id, so you have layout cache unique for
each product or category!
Ivan Chepurnyi
Solution
Meet Magento
Add an observer to controller_action_layout_load_before,
check loaded handles and remove items that match starts with
CATEGORY_ and PRODUCT_, except PRODUCT_TYPE.
Ivan Chepurnyi
Solution
Meet Magento
public function optimizeLayout($observer)
{
$update = $observer->getLayout()->getUpdate();
foreach ($update->getHandles() as $handle) {
if (strpos($handle, 'CATEGORY_') === 0
|| (strpos($handle, 'PRODUCT_') === 0
&& strpos($handle, 'PRODUCT_TYPE_') === false)) {
$update->removeHandle($handle);
}
}
}
Example of Observer
Ivan Chepurnyi
Drawback
Meet Magento
Widgets based on Category Id and Product Id handles will not
work. Hovewer you always have for them “Custom Layout
Update XML” attribute on entity level.
Ivan Chepurnyi
Problem #2
Meet Magento
No cache for CMS Blocks
Magento doesn’t cache them by default. On average projects
you have up to 10-20 CMS blocks that can be edited by
customer on every page.
Ivan Chepurnyi
Solution
Meet Magento
Add an observer to core_block_abstract_to_html_before,
and specify required cache information for the block, like cache
key (that is a block identifier) and cache tags
(Mage_Cms_Model_Block::CACHE_TAG).
Ivan Chepurnyi
Solution
Meet Magento
public function optimizeCmsBlocksCache($observer)
{
$block = $observer->getBlock();
if ($block instanceof Mage_Cms_Block_Widget_Block
|| $block instanceof Mage_Cms_Block_Block) {
$cacheKeyData = array(
Mage_Cms_Model_Block::CACHE_TAG,
$block->getBlockId(),
Mage::app()->getStore()->getId()
);
$block->setCacheKey(implode('_', $cacheKeyData));
$block->setCacheTags(
array(Mage_Cms_Model_Block::CACHE_TAG)
);
$block->setCacheLifetime(false);
}
}
Example of Observer
Ivan Chepurnyi
Problem #3
Meet Magento
Magento top menu
Since CE 1.7 version of Magento, they moved menu to another
block, but forget to add caching to it. So now each page load
spends from 100-300mson building top menu!
And the more categories you have, the more time is spent!
Ivan Chepurnyi
Solution
Meet Magento
1. Add a cache tags via observer similar to optimization of
CMS blocks. The difference only, that you will need to add
category cache tag instead:
Mage_Catalog_Model_Category::CACHE_TAG
2. Rewrite Mage_Page_Block_Html_Topmenu to add
category id into the menu node class name. Yes, there is no
event for this :(
3. Add JS on the page that will use current category id for
highlighting top menu item.
Ivan Chepurnyi
Solution
Meet Magento
public function optimizeNavigationCache($observer)
{
$block = $observer;
if ($block instanceof Mage_Page_Block_Html_Topmenu) {
$cacheKeyData = array(
Mage_Catalog_Model_Category::CACHE_TAG,
'NAVIGATION',
Mage::app()->getStore()->getCode()
);
$block->setCacheKey(implode('_', $cacheKeyData));
$block->setCacheTags(
array(Mage_Catalog_Model_Category::CACHE_TAG)
);
$block->setCacheLifetime(false);
}
}
Example of Observer
Ivan Chepurnyi
Solution
Meet Magento
protected function _getMenuItemClasses(Varien_Data_Tree_Node $item)
{
$classes = parent::_getMenuItemClasses($item);
// Will be something like category-node-#id
$classes[] = $item->getId();
return $classes;
}
Overridden Block Method
Ivan Chepurnyi
Solution
Meet Magento
JS implementation is up to you.
I believe you can do that yourself :)
Ivan Chepurnyi
Problem #4
Meet Magento
Magento Visitor Logging
Mage_Log and Mage_Report modules perform a write
operation on every page view to own tables. After few monthes
it becomes very slow, since size of the tables increasing
dramatically.
Ivan Chepurnyi
Solution
Meet Magento
1. Remove observers of Mage_Log and Mage_Reports
module by config.xml
– Events for Mage_Log: http://bit.ly/magelog
– Events for Mage_Reports: http://bit.ly/magereports
It will remove observers by using of observer type disabled
and repeating the observer XML path.
Ivan Chepurnyi
Drawback
Meet Magento
You will not be able to use native Magento reports for visitors
activity. Hovewer it they are irrelevant, since most of merchants
don’t use it, since they are using other analytics software.
Ivan Chepurnyi Meet Magento
Category Pages & Product Pages
Ivan Chepurnyi
Problem #1
Meet Magento
Layered Navigation
For each attribute you have in Magento and that is marked as
filtrable, it will make a call to getAllOptions() of attribute source
model. Even if there is no filter results for it, it will invoke
attribute option collection load.
For merchants who have a lot of attributes, it is a huge
performance bottleneck.
Ivan Chepurnyi
Solution
Meet Magento
• Remove collection usage usage for each item by rewriting
Mage_Eav_Model_Entity_Attribute_Source_Table class.
• Implement a static method, that will load values for all
attributes at once. If you will not use objects, it won’t take too
much memory.
• Override getAllOptions() method to use your static method.
• You can find class by this url: http://bit.ly/mageoption
Ivan Chepurnyi
What it does?
Meet Magento
// This one will use collection getData() method
// to retrieve array items instead of collection of objects.
Mage::getResourceModel('eav/entity_attribute_option_collection')
->setPositionOrder('asc')
->setStoreFilter($storeId)
->getData();
On the first call to getAllOptions() it will preload all
attribute values for current store in array format.
Ivan Chepurnyi
Problem #2
Meet Magento
Dropdown Options on Product Page
The problem is the same as with layered navigation, but not
that much visible if you don’t have too much dropdown
attributes to show. Product getOptionText() uses the same
getAllOptions() method call.
This one is automatically fixed by fixing previous one.
Ivan Chepurnyi
What it does?
Meet Magento
$key = self::_getCombinedKey($storeId, $value, 'store');
if (isset(self::$_preloadedOptionHash[$key])) {
return self::$_preloadedOptionHash[$key];
}
return false;
On the first call to getOptionText() it will preload all
attribute option_id to value array for current store.
Ivan Chepurnyi
Problem #3
Meet Magento
Configurable Products
Magento is not using flat version of products for configurable
products children retrieval. So every configurable product page
is a bottleneck, especially for fashion retailers.
Ivan Chepurnyi
Solution
Meet Magento
1. Rewrite the class with this long name:
Mage_Catalog_Model_Resource_Product_Type_Configurable_Product_Collection
2. Overriden isEnabledFlat() method that should return the real
information about flat availability.
1. Make sure that attributes, that your customer is using, are
included into the flat version of catalog. Mark them as
“used_in_product_listing”.
2. Fix Magento bug with filters by attribute id
Ivan Chepurnyi
Solution
Meet Magento
public function isEnabledFlat()
{
return Mage_Catalog_Model_Resource_Product_Collection::isEnabledFlat();
}
public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner')
{
if ($this->isEnabledFlat() && is_numeric($attribute)) {
$attribute = $this->getEntity()
->getAttribute($attribute)->getAttributeCode();
}
return parent::addAttributeToFilter($attribute, $condition, $joinType);
}
Overriden Collection
Ivan Chepurnyi Meet Magento
Checkout Pages
Ivan Chepurnyi
Problem #1
Meet Magento
Catalog Price Rules
Each time when Magento calls collectTotals() method on
quote object, it walks though all items in the quote and invoked
getFinalPrice() method on your product. This method
dispatches catalog_product_get_final_price event, that is
observed by Mage_CatalogRule module.
Ivan Chepurnyi
Solution
Meet Magento
1. Rewrite Mage_CatalogRule_Model_Observer class and
create a new method that will preload rule prices for quote.
2. Define $_preloadedPrices property to cache results per quote
object.
3. Add an observer in configuration for
sales_quote_collect_totals_before event, for original core class
alias, but with the method you’ve created.
Full observer class can be found at this url: http://bit.ly/magerule
Ivan Chepurnyi
Solution
Meet Magento
public function beforeCollectTotals(Varien_Event_Observer $observer)
{
// … Omited retrieval of product ids and customer group with website
$cacheKey = spl_object_hash($quote);
if (!isset($this->_preloadedPrices[$cacheKey])) {
$this->_preloadedPrices[$cacheKey] =
Mage::getResourceSingleton('catalogrule/rule')
->getRulePrices($date, $websiteId, $groupId, $productIds);
}
foreach ($this->_preloadedPrices[$cacheKey] as $productId => $price) {
$key = implode('|', array($date, $websiteId, $groupId, $productId));
$this->_rulePrices[$key] = $price;
}
}
Created method code
Ivan Chepurnyi
There are more issues…
Meet Magento
But it is too much for one presentation :)
Let’s better talk about high loaded projects!
Ivan Chepurnyi Meet Magento
Are you using Varnish for your projects?
Ivan Chepurnyi
Varnish Issues
Meet Magento
Common issues caused by developers, when they use
Varnish on the project
• Developers usually hide poor code quality behind front
cache server
• Doing backend callbacks for functionality that can be fully
done by modern browser in JavaScript.
• Caching static files by Varnish
Ivan Chepurnyi
ESI include is an evil for Magento
Meet Magento
Only when the content for ESI include can be cached by
Varnish. It doesn’t make to make ESI includes for shopping
cart, compare and recently viewed reports.
Ivan Chepurnyi
Goog ESI includes
Meet Magento
• Magento Top Menu Navigation
You don’t need to clear all varnish cached pages, if your
customer updated the name of category or re-arranged the
position of items.
• CMS Static Blocks
If you have a static that is used almost on every page, you don’t
need to clear page cache, if its content changed.
Ivan Chepurnyi
AJAX Callbacks Issue
Meet Magento
AJAX call should be done only when needed.
Do not perform a bunch of calls just because the data should
be loaded from the server. It is always possible to decrease
amount of calls by using your frontend skills.
Ivan Chepurnyi
Use Cookies & HTML5!
Meet Magento
• You can always set a custom cookie in Magento when
customer:
– Adds a product to a cart
– Logs in or logs out
– Adds a product to a compare list
• You always can store up to 2Mb of data into sessionStorage
of your visitor browser! Only IE7 doesn’t support it.
Ivan Chepurnyi
How it can help you?
Meet Magento
• You can decrease amount of AJAX calls to the number of
real user actions.
– Customer adds product to cart, you make an ajax call to
update session storage
– Customer logs in, you make and ajax call to update the it
again
– Customer adds product to wishlist or compare products
list, you update a session storage.
So in the end it should be1 action – 1 AJAX call,
and NOT 1 page view – 1 AJAX call!
Ivan Chepurnyi
Recently Viewed Products
Meet Magento
For recently viewed products, you even don’t need to make any
AJAX calls
– Render a hidden block on the product page
– When customer views a product, add this hidden block to
session storage
– On any other page, just render data by JavaScript!
Ivan Chepurnyi
Conclusion
Meet Magento
Be smart and use Varnish correctly!
Ivan Chepurnyi
OpenSource Roadmap 2014
Meet Magento
1. Finalize EcomDev_Varnish module and make it open
source;
2. EcomDev_PHPUnit refactoring for API based fixtures;
3. Working on EcomDev_Index module, to provide alternative
of standard indexation mechanism in Magento:
– Flat Indexers (failover indexation)
– UrlRewrites (full refactor of existing module
– Layered Navigation (Sphinx)
– Better Search (Sphinx)
Ivan Chepurnyi Meet Magento
Thank You!
Questions?

Mais conteúdo relacionado

Mais procurados

WordPress plugin #2
WordPress plugin #2WordPress plugin #2
WordPress plugin #2giwoolee
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shintutorialsruby
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceParashuram N
 
Apex 5 plugins for everyone version 2018
Apex 5 plugins for everyone   version 2018Apex 5 plugins for everyone   version 2018
Apex 5 plugins for everyone version 2018Alan Arentsen
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOdoo
 
ILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseRené Winkelmeyer
 
Cakephp's Cache
Cakephp's CacheCakephp's Cache
Cakephp's Cachevl
 
Vue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and VuexVue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and VuexChristoffer Noring
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On RailsWen-Tien Chang
 
Utilization of zend an ultimate alternate for intense data processing
Utilization of zend  an ultimate alternate for intense data processingUtilization of zend  an ultimate alternate for intense data processing
Utilization of zend an ultimate alternate for intense data processingCareer at Elsner
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2Javier Eguiluz
 
날로 먹는 Django admin 활용
날로 먹는 Django admin 활용날로 먹는 Django admin 활용
날로 먹는 Django admin 활용KyeongMook "Kay" Cha
 
AtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlassian
 
Manipulating Magento - Meet Magento Netherlands 2018
Manipulating Magento - Meet Magento Netherlands 2018Manipulating Magento - Meet Magento Netherlands 2018
Manipulating Magento - Meet Magento Netherlands 2018Joke Puts
 

Mais procurados (20)

Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
 
WordPress plugin #2
WordPress plugin #2WordPress plugin #2
WordPress plugin #2
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shin
 
RicoLiveGrid
RicoLiveGridRicoLiveGrid
RicoLiveGrid
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and Performance
 
Apex 5 plugins for everyone version 2018
Apex 5 plugins for everyone   version 2018Apex 5 plugins for everyone   version 2018
Apex 5 plugins for everyone version 2018
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI Framework
 
ILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterprise
 
Cakephp's Cache
Cakephp's CacheCakephp's Cache
Cakephp's Cache
 
Vue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and VuexVue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and Vuex
 
WCLV13 JavaScript
WCLV13 JavaScriptWCLV13 JavaScript
WCLV13 JavaScript
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Utilization of zend an ultimate alternate for intense data processing
Utilization of zend  an ultimate alternate for intense data processingUtilization of zend  an ultimate alternate for intense data processing
Utilization of zend an ultimate alternate for intense data processing
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
 
Satchmo
SatchmoSatchmo
Satchmo
 
AngularJs-training
AngularJs-trainingAngularJs-training
AngularJs-training
 
날로 먹는 Django admin 활용
날로 먹는 Django admin 활용날로 먹는 Django admin 활용
날로 먹는 Django admin 활용
 
AtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using now
 
Manipulating Magento - Meet Magento Netherlands 2018
Manipulating Magento - Meet Magento Netherlands 2018Manipulating Magento - Meet Magento Netherlands 2018
Manipulating Magento - Meet Magento Netherlands 2018
 

Destaque

Ecommerce y Tiendas Virtuales: Woocommerce, Prestashop, Magento
Ecommerce y Tiendas Virtuales: Woocommerce, Prestashop, MagentoEcommerce y Tiendas Virtuales: Woocommerce, Prestashop, Magento
Ecommerce y Tiendas Virtuales: Woocommerce, Prestashop, MagentoJavier Merchán Correa
 
Improved Layered Navigation: Magento Extension by Amasty. User Guide.
Improved Layered Navigation: Magento Extension by Amasty. User Guide.Improved Layered Navigation: Magento Extension by Amasty. User Guide.
Improved Layered Navigation: Magento Extension by Amasty. User Guide.Amasty
 
Surprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusinessSurprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusinessDivante
 
Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)Divante
 
Omnichannel Customer Experience
Omnichannel Customer ExperienceOmnichannel Customer Experience
Omnichannel Customer ExperienceDivante
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedSlideShare
 

Destaque (6)

Ecommerce y Tiendas Virtuales: Woocommerce, Prestashop, Magento
Ecommerce y Tiendas Virtuales: Woocommerce, Prestashop, MagentoEcommerce y Tiendas Virtuales: Woocommerce, Prestashop, Magento
Ecommerce y Tiendas Virtuales: Woocommerce, Prestashop, Magento
 
Improved Layered Navigation: Magento Extension by Amasty. User Guide.
Improved Layered Navigation: Magento Extension by Amasty. User Guide.Improved Layered Navigation: Magento Extension by Amasty. User Guide.
Improved Layered Navigation: Magento Extension by Amasty. User Guide.
 
Surprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusinessSurprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusiness
 
Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)
 
Omnichannel Customer Experience
Omnichannel Customer ExperienceOmnichannel Customer Experience
Omnichannel Customer Experience
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
 

Semelhante a Fixing Magento Core for Better Performance

Magento 2 integration tests
Magento 2 integration testsMagento 2 integration tests
Magento 2 integration testsDusan Lukic
 
Meet Magento Belarus debug Pavel Novitsky (eng)
Meet Magento Belarus debug Pavel Novitsky (eng)Meet Magento Belarus debug Pavel Novitsky (eng)
Meet Magento Belarus debug Pavel Novitsky (eng)Pavel Novitsky
 
Magento Attributes - Fresh View
Magento Attributes - Fresh ViewMagento Attributes - Fresh View
Magento Attributes - Fresh ViewAlex Gotgelf
 
Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
Meet Magento DE 2016 - Kristof Ringleff - Growing up with MagentoMeet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
Meet Magento DE 2016 - Kristof Ringleff - Growing up with MagentoKristof Ringleff
 
Implement rich snippets in your webshop
Implement rich snippets in your webshopImplement rich snippets in your webshop
Implement rich snippets in your webshopArjen Miedema
 
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014Chad Windnagle
 
Mason - A Template system for us Perl programmers
Mason - A Template system for us Perl programmersMason - A Template system for us Perl programmers
Mason - A Template system for us Perl programmersJerome Eteve
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress WebsitesKyle Cearley
 
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016Dusan Lukic
 
How to Create Module to Track Affiliate Conversions?
How to Create Module to Track Affiliate Conversions?How to Create Module to Track Affiliate Conversions?
How to Create Module to Track Affiliate Conversions?damienwoods
 
Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!Ivan Chepurnyi
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHendy Irawan
 
PrestaShop Kathmandu Ecommerce Meetup #2
PrestaShop Kathmandu Ecommerce Meetup #2PrestaShop Kathmandu Ecommerce Meetup #2
PrestaShop Kathmandu Ecommerce Meetup #2Hem Pokhrel
 

Semelhante a Fixing Magento Core for Better Performance (20)

Growing up with Magento
Growing up with MagentoGrowing up with Magento
Growing up with Magento
 
Magento 2 integration tests
Magento 2 integration testsMagento 2 integration tests
Magento 2 integration tests
 
Meet Magento Belarus debug Pavel Novitsky (eng)
Meet Magento Belarus debug Pavel Novitsky (eng)Meet Magento Belarus debug Pavel Novitsky (eng)
Meet Magento Belarus debug Pavel Novitsky (eng)
 
Magento++
Magento++Magento++
Magento++
 
Magento Attributes - Fresh View
Magento Attributes - Fresh ViewMagento Attributes - Fresh View
Magento Attributes - Fresh View
 
Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
Meet Magento DE 2016 - Kristof Ringleff - Growing up with MagentoMeet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
 
Eclipse Tricks
Eclipse TricksEclipse Tricks
Eclipse Tricks
 
Implement rich snippets in your webshop
Implement rich snippets in your webshopImplement rich snippets in your webshop
Implement rich snippets in your webshop
 
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
 
WordCamp Praga 2015
WordCamp Praga 2015WordCamp Praga 2015
WordCamp Praga 2015
 
Mason - A Template system for us Perl programmers
Mason - A Template system for us Perl programmersMason - A Template system for us Perl programmers
Mason - A Template system for us Perl programmers
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
 
How to Create Module to Track Affiliate Conversions?
How to Create Module to Track Affiliate Conversions?How to Create Module to Track Affiliate Conversions?
How to Create Module to Track Affiliate Conversions?
 
Django design-patterns
Django design-patternsDjango design-patterns
Django design-patterns
 
Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
 
PrestaShop Kathmandu Ecommerce Meetup #2
PrestaShop Kathmandu Ecommerce Meetup #2PrestaShop Kathmandu Ecommerce Meetup #2
PrestaShop Kathmandu Ecommerce Meetup #2
 
Patterns in PHP
Patterns in PHPPatterns in PHP
Patterns in PHP
 
Catalog display
Catalog displayCatalog display
Catalog display
 

Mais de Meet Magento Spain

Mobile Commerce y Magento - Jaime Lopez
Mobile Commerce y Magento - Jaime LopezMobile Commerce y Magento - Jaime Lopez
Mobile Commerce y Magento - Jaime LopezMeet Magento Spain
 
SEO - Claves Estratégicas y Operativas - Néstor Tejero
SEO - Claves Estratégicas y Operativas - Néstor TejeroSEO - Claves Estratégicas y Operativas - Néstor Tejero
SEO - Claves Estratégicas y Operativas - Néstor TejeroMeet Magento Spain
 
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirlResponsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirlMeet Magento Spain
 
Magento and Continuous Integration - Damian Luszczymak
Magento and Continuous Integration - Damian LuszczymakMagento and Continuous Integration - Damian Luszczymak
Magento and Continuous Integration - Damian LuszczymakMeet Magento Spain
 
One page shops with Magento & Angular Js - Vinai Kopp
One page shops with Magento & Angular Js - Vinai KoppOne page shops with Magento & Angular Js - Vinai Kopp
One page shops with Magento & Angular Js - Vinai KoppMeet Magento Spain
 
Hackathon MM14ES - Fabian Blechschmidt
Hackathon MM14ES - Fabian BlechschmidtHackathon MM14ES - Fabian Blechschmidt
Hackathon MM14ES - Fabian BlechschmidtMeet Magento Spain
 
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerceCómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerceMeet Magento Spain
 
UX: Responsabilidad Creativa en Ecommerce - Luz de León
UX: Responsabilidad Creativa en Ecommerce - Luz de LeónUX: Responsabilidad Creativa en Ecommerce - Luz de León
UX: Responsabilidad Creativa en Ecommerce - Luz de LeónMeet Magento Spain
 
Social Commerce - Fernando Polo
Social Commerce - Fernando Polo Social Commerce - Fernando Polo
Social Commerce - Fernando Polo Meet Magento Spain
 
La importancia del paquete 2.0 - Marc Brayo Seur
La importancia del paquete 2.0 - Marc Brayo SeurLa importancia del paquete 2.0 - Marc Brayo Seur
La importancia del paquete 2.0 - Marc Brayo SeurMeet Magento Spain
 
Responsive Web Design - Tom Robertshaw
Responsive Web Design - Tom RobertshawResponsive Web Design - Tom Robertshaw
Responsive Web Design - Tom RobertshawMeet Magento Spain
 

Mais de Meet Magento Spain (12)

Mobile Commerce y Magento - Jaime Lopez
Mobile Commerce y Magento - Jaime LopezMobile Commerce y Magento - Jaime Lopez
Mobile Commerce y Magento - Jaime Lopez
 
SEO - Claves Estratégicas y Operativas - Néstor Tejero
SEO - Claves Estratégicas y Operativas - Néstor TejeroSEO - Claves Estratégicas y Operativas - Néstor Tejero
SEO - Claves Estratégicas y Operativas - Néstor Tejero
 
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirlResponsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
 
Magento and Continuous Integration - Damian Luszczymak
Magento and Continuous Integration - Damian LuszczymakMagento and Continuous Integration - Damian Luszczymak
Magento and Continuous Integration - Damian Luszczymak
 
One page shops with Magento & Angular Js - Vinai Kopp
One page shops with Magento & Angular Js - Vinai KoppOne page shops with Magento & Angular Js - Vinai Kopp
One page shops with Magento & Angular Js - Vinai Kopp
 
Hackathon MM14ES - Fabian Blechschmidt
Hackathon MM14ES - Fabian BlechschmidtHackathon MM14ES - Fabian Blechschmidt
Hackathon MM14ES - Fabian Blechschmidt
 
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerceCómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerce
 
UX: Responsabilidad Creativa en Ecommerce - Luz de León
UX: Responsabilidad Creativa en Ecommerce - Luz de LeónUX: Responsabilidad Creativa en Ecommerce - Luz de León
UX: Responsabilidad Creativa en Ecommerce - Luz de León
 
SEO Magento - Irene Horna
SEO Magento - Irene HornaSEO Magento - Irene Horna
SEO Magento - Irene Horna
 
Social Commerce - Fernando Polo
Social Commerce - Fernando Polo Social Commerce - Fernando Polo
Social Commerce - Fernando Polo
 
La importancia del paquete 2.0 - Marc Brayo Seur
La importancia del paquete 2.0 - Marc Brayo SeurLa importancia del paquete 2.0 - Marc Brayo Seur
La importancia del paquete 2.0 - Marc Brayo Seur
 
Responsive Web Design - Tom Robertshaw
Responsive Web Design - Tom RobertshawResponsive Web Design - Tom Robertshaw
Responsive Web Design - Tom Robertshaw
 

Último

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 

Último (20)

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 

Fixing Magento Core for Better Performance

  • 1. Fixing Magento Core for Better Performance Ivan Chepurnyi Co Owner / Trainer EcomDev BV
  • 2. Ivan Chepurnyi About me Meet Magento • I am Ukrainian • Technical Consultant, Co-owner at EcomDev B.V. • Was one of the first five developers in original Magento core team • Providing trainings and coaching Magento Developers in Europe • Main areas of my expertise: – System Architecture – Performance Optimization – Test Driven Development – Complex Customizations
  • 3. Ivan Chepurnyi Regular Store Bottlenecks Meet Magento • Overall Problems • Category Pages • Product Pages • Checkout Pages
  • 4. Ivan Chepurnyi Meet Magento Overall Problems
  • 5. Ivan Chepurnyi Problem #1 Meet Magento Non optimized layout handles usage Magento adds on every category and product page a layout handle with its entity id, so you have layout cache unique for each product or category!
  • 6. Ivan Chepurnyi Solution Meet Magento Add an observer to controller_action_layout_load_before, check loaded handles and remove items that match starts with CATEGORY_ and PRODUCT_, except PRODUCT_TYPE.
  • 7. Ivan Chepurnyi Solution Meet Magento public function optimizeLayout($observer) { $update = $observer->getLayout()->getUpdate(); foreach ($update->getHandles() as $handle) { if (strpos($handle, 'CATEGORY_') === 0 || (strpos($handle, 'PRODUCT_') === 0 && strpos($handle, 'PRODUCT_TYPE_') === false)) { $update->removeHandle($handle); } } } Example of Observer
  • 8. Ivan Chepurnyi Drawback Meet Magento Widgets based on Category Id and Product Id handles will not work. Hovewer you always have for them “Custom Layout Update XML” attribute on entity level.
  • 9. Ivan Chepurnyi Problem #2 Meet Magento No cache for CMS Blocks Magento doesn’t cache them by default. On average projects you have up to 10-20 CMS blocks that can be edited by customer on every page.
  • 10. Ivan Chepurnyi Solution Meet Magento Add an observer to core_block_abstract_to_html_before, and specify required cache information for the block, like cache key (that is a block identifier) and cache tags (Mage_Cms_Model_Block::CACHE_TAG).
  • 11. Ivan Chepurnyi Solution Meet Magento public function optimizeCmsBlocksCache($observer) { $block = $observer->getBlock(); if ($block instanceof Mage_Cms_Block_Widget_Block || $block instanceof Mage_Cms_Block_Block) { $cacheKeyData = array( Mage_Cms_Model_Block::CACHE_TAG, $block->getBlockId(), Mage::app()->getStore()->getId() ); $block->setCacheKey(implode('_', $cacheKeyData)); $block->setCacheTags( array(Mage_Cms_Model_Block::CACHE_TAG) ); $block->setCacheLifetime(false); } } Example of Observer
  • 12. Ivan Chepurnyi Problem #3 Meet Magento Magento top menu Since CE 1.7 version of Magento, they moved menu to another block, but forget to add caching to it. So now each page load spends from 100-300mson building top menu! And the more categories you have, the more time is spent!
  • 13. Ivan Chepurnyi Solution Meet Magento 1. Add a cache tags via observer similar to optimization of CMS blocks. The difference only, that you will need to add category cache tag instead: Mage_Catalog_Model_Category::CACHE_TAG 2. Rewrite Mage_Page_Block_Html_Topmenu to add category id into the menu node class name. Yes, there is no event for this :( 3. Add JS on the page that will use current category id for highlighting top menu item.
  • 14. Ivan Chepurnyi Solution Meet Magento public function optimizeNavigationCache($observer) { $block = $observer; if ($block instanceof Mage_Page_Block_Html_Topmenu) { $cacheKeyData = array( Mage_Catalog_Model_Category::CACHE_TAG, 'NAVIGATION', Mage::app()->getStore()->getCode() ); $block->setCacheKey(implode('_', $cacheKeyData)); $block->setCacheTags( array(Mage_Catalog_Model_Category::CACHE_TAG) ); $block->setCacheLifetime(false); } } Example of Observer
  • 15. Ivan Chepurnyi Solution Meet Magento protected function _getMenuItemClasses(Varien_Data_Tree_Node $item) { $classes = parent::_getMenuItemClasses($item); // Will be something like category-node-#id $classes[] = $item->getId(); return $classes; } Overridden Block Method
  • 16. Ivan Chepurnyi Solution Meet Magento JS implementation is up to you. I believe you can do that yourself :)
  • 17. Ivan Chepurnyi Problem #4 Meet Magento Magento Visitor Logging Mage_Log and Mage_Report modules perform a write operation on every page view to own tables. After few monthes it becomes very slow, since size of the tables increasing dramatically.
  • 18. Ivan Chepurnyi Solution Meet Magento 1. Remove observers of Mage_Log and Mage_Reports module by config.xml – Events for Mage_Log: http://bit.ly/magelog – Events for Mage_Reports: http://bit.ly/magereports It will remove observers by using of observer type disabled and repeating the observer XML path.
  • 19. Ivan Chepurnyi Drawback Meet Magento You will not be able to use native Magento reports for visitors activity. Hovewer it they are irrelevant, since most of merchants don’t use it, since they are using other analytics software.
  • 20. Ivan Chepurnyi Meet Magento Category Pages & Product Pages
  • 21. Ivan Chepurnyi Problem #1 Meet Magento Layered Navigation For each attribute you have in Magento and that is marked as filtrable, it will make a call to getAllOptions() of attribute source model. Even if there is no filter results for it, it will invoke attribute option collection load. For merchants who have a lot of attributes, it is a huge performance bottleneck.
  • 22. Ivan Chepurnyi Solution Meet Magento • Remove collection usage usage for each item by rewriting Mage_Eav_Model_Entity_Attribute_Source_Table class. • Implement a static method, that will load values for all attributes at once. If you will not use objects, it won’t take too much memory. • Override getAllOptions() method to use your static method. • You can find class by this url: http://bit.ly/mageoption
  • 23. Ivan Chepurnyi What it does? Meet Magento // This one will use collection getData() method // to retrieve array items instead of collection of objects. Mage::getResourceModel('eav/entity_attribute_option_collection') ->setPositionOrder('asc') ->setStoreFilter($storeId) ->getData(); On the first call to getAllOptions() it will preload all attribute values for current store in array format.
  • 24. Ivan Chepurnyi Problem #2 Meet Magento Dropdown Options on Product Page The problem is the same as with layered navigation, but not that much visible if you don’t have too much dropdown attributes to show. Product getOptionText() uses the same getAllOptions() method call. This one is automatically fixed by fixing previous one.
  • 25. Ivan Chepurnyi What it does? Meet Magento $key = self::_getCombinedKey($storeId, $value, 'store'); if (isset(self::$_preloadedOptionHash[$key])) { return self::$_preloadedOptionHash[$key]; } return false; On the first call to getOptionText() it will preload all attribute option_id to value array for current store.
  • 26. Ivan Chepurnyi Problem #3 Meet Magento Configurable Products Magento is not using flat version of products for configurable products children retrieval. So every configurable product page is a bottleneck, especially for fashion retailers.
  • 27. Ivan Chepurnyi Solution Meet Magento 1. Rewrite the class with this long name: Mage_Catalog_Model_Resource_Product_Type_Configurable_Product_Collection 2. Overriden isEnabledFlat() method that should return the real information about flat availability. 1. Make sure that attributes, that your customer is using, are included into the flat version of catalog. Mark them as “used_in_product_listing”. 2. Fix Magento bug with filters by attribute id
  • 28. Ivan Chepurnyi Solution Meet Magento public function isEnabledFlat() { return Mage_Catalog_Model_Resource_Product_Collection::isEnabledFlat(); } public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner') { if ($this->isEnabledFlat() && is_numeric($attribute)) { $attribute = $this->getEntity() ->getAttribute($attribute)->getAttributeCode(); } return parent::addAttributeToFilter($attribute, $condition, $joinType); } Overriden Collection
  • 29. Ivan Chepurnyi Meet Magento Checkout Pages
  • 30. Ivan Chepurnyi Problem #1 Meet Magento Catalog Price Rules Each time when Magento calls collectTotals() method on quote object, it walks though all items in the quote and invoked getFinalPrice() method on your product. This method dispatches catalog_product_get_final_price event, that is observed by Mage_CatalogRule module.
  • 31. Ivan Chepurnyi Solution Meet Magento 1. Rewrite Mage_CatalogRule_Model_Observer class and create a new method that will preload rule prices for quote. 2. Define $_preloadedPrices property to cache results per quote object. 3. Add an observer in configuration for sales_quote_collect_totals_before event, for original core class alias, but with the method you’ve created. Full observer class can be found at this url: http://bit.ly/magerule
  • 32. Ivan Chepurnyi Solution Meet Magento public function beforeCollectTotals(Varien_Event_Observer $observer) { // … Omited retrieval of product ids and customer group with website $cacheKey = spl_object_hash($quote); if (!isset($this->_preloadedPrices[$cacheKey])) { $this->_preloadedPrices[$cacheKey] = Mage::getResourceSingleton('catalogrule/rule') ->getRulePrices($date, $websiteId, $groupId, $productIds); } foreach ($this->_preloadedPrices[$cacheKey] as $productId => $price) { $key = implode('|', array($date, $websiteId, $groupId, $productId)); $this->_rulePrices[$key] = $price; } } Created method code
  • 33. Ivan Chepurnyi There are more issues… Meet Magento But it is too much for one presentation :) Let’s better talk about high loaded projects!
  • 34. Ivan Chepurnyi Meet Magento Are you using Varnish for your projects?
  • 35. Ivan Chepurnyi Varnish Issues Meet Magento Common issues caused by developers, when they use Varnish on the project • Developers usually hide poor code quality behind front cache server • Doing backend callbacks for functionality that can be fully done by modern browser in JavaScript. • Caching static files by Varnish
  • 36. Ivan Chepurnyi ESI include is an evil for Magento Meet Magento Only when the content for ESI include can be cached by Varnish. It doesn’t make to make ESI includes for shopping cart, compare and recently viewed reports.
  • 37. Ivan Chepurnyi Goog ESI includes Meet Magento • Magento Top Menu Navigation You don’t need to clear all varnish cached pages, if your customer updated the name of category or re-arranged the position of items. • CMS Static Blocks If you have a static that is used almost on every page, you don’t need to clear page cache, if its content changed.
  • 38. Ivan Chepurnyi AJAX Callbacks Issue Meet Magento AJAX call should be done only when needed. Do not perform a bunch of calls just because the data should be loaded from the server. It is always possible to decrease amount of calls by using your frontend skills.
  • 39. Ivan Chepurnyi Use Cookies & HTML5! Meet Magento • You can always set a custom cookie in Magento when customer: – Adds a product to a cart – Logs in or logs out – Adds a product to a compare list • You always can store up to 2Mb of data into sessionStorage of your visitor browser! Only IE7 doesn’t support it.
  • 40. Ivan Chepurnyi How it can help you? Meet Magento • You can decrease amount of AJAX calls to the number of real user actions. – Customer adds product to cart, you make an ajax call to update session storage – Customer logs in, you make and ajax call to update the it again – Customer adds product to wishlist or compare products list, you update a session storage. So in the end it should be1 action – 1 AJAX call, and NOT 1 page view – 1 AJAX call!
  • 41. Ivan Chepurnyi Recently Viewed Products Meet Magento For recently viewed products, you even don’t need to make any AJAX calls – Render a hidden block on the product page – When customer views a product, add this hidden block to session storage – On any other page, just render data by JavaScript!
  • 42. Ivan Chepurnyi Conclusion Meet Magento Be smart and use Varnish correctly!
  • 43. Ivan Chepurnyi OpenSource Roadmap 2014 Meet Magento 1. Finalize EcomDev_Varnish module and make it open source; 2. EcomDev_PHPUnit refactoring for API based fixtures; 3. Working on EcomDev_Index module, to provide alternative of standard indexation mechanism in Magento: – Flat Indexers (failover indexation) – UrlRewrites (full refactor of existing module – Layered Navigation (Sphinx) – Better Search (Sphinx)
  • 44. Ivan Chepurnyi Meet Magento Thank You!