0

I have just launched a new Magento 1.9.1.4 site that has been in development for a long time. Right before launch, I went through my "speed up" checklist:

  • Compilation: on
  • Caching: on
  • Flat databases: on
  • Combine CSS/JS: on
  • Logging: off
  • GZip: on
  • Plus several other trivial tweaks...

However, I was still getting a page load time of 12-16 seconds on my category pages! After enabling the profiler, I started at the bottom of the list (innermost child code?) and found the following lines with high time and memory usage:

| Code Profiler | Time | Cnt | Emalloc | RealMem |
|---------------|------|-----|---------|---------|
| frontend/{package}/{theme}/template/catalog/product/price.phtml | 10.1435 | 27 | 14,295,328 | 20,971,520 |
|---------------|------|-----|---------|---------|
| CONFIGURABLE:Mage_Catalog_Model_Product_Type_Configurable::getConfigurableAttributes | 9.8808 | 27 | 13,653,472 | 19,398,656 |
|---------------|------|-----|---------|---------|
| TTT2:Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection::_afterLoad | 3.3624 | 27 | 9,510,240 | 15,204,352 |
| CONFIGURABLE:Amasty_Conf_Model_Catalog_Product_Type_Configurable::getUsedProducts | 3.3584 | 108 | 10,730,968 | 15,204,352 |
|---------------|------|-----|---------|---------|
| TTT4:Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection::_afterLoad | 5.1512 | 27 | 3,266,096 | 3,407,872 |
| 

So, thinking I royally screwed up the code in my theme's price.phtml, I removed it from the server to test using Magento's default price.phtml. However, I found that code to be only marginally better:

| Code Profiler | Time | Cnt | Emalloc | RealMem |
|---------------|------|-----|---------|---------|
| frontend/base/default/template/catalog/product/price.phtml | 8.8124 | 27 | 14,278,832 | 20,971,520 |
|---------------|------|-----|---------|---------|
| CONFIGURABLE:Mage_Catalog_Model_Product_Type_Configurable::getConfigurableAttributes | 8.6064 | 27 | 13,649,584 | 19,136,512 |
|---------------|------|-----|---------|---------|
| TTT2:Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection::_afterLoad | 3.0117 | 27 | 9,509,048 | 14,942,208 |
| CONFIGURABLE:Amasty_Conf_Model_Catalog_Product_Type_Configurable::getUsedProducts | 3.0080 | 108 | 10,730,480 | 14,942,208 |
|---------------|------|-----|---------|---------|
| TTT4:Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection::_afterLoad | 4.4072 | 27 | 3,263,456 | 3,407,872 |
| 

So, it seems that I'm missing something here to get the site/server into production mode or something is really messed up with the product structure. Can someone lend a hand as to why Magento's default files (and my custom theme files) are taking so long to load after optimization?


Note: The above specs are from a category page in grid view with 27 products (obviously from the "Cnt" column).

  • catalog/product/price.phtml this file really makes trouble with performance. Core Magento code is not at all optimized here I believe. – Rajeev K Tomy Nov 16 '16 at 4:02
  • @RajeevKTomy, I'm just using the default price.html as a reference, but surely Magento's core files can do better than 9 seconds on a single block of code! – Michael Yaeger Nov 16 '16 at 4:15
2

The solution ended up being that I was using the following line inside the loop for my products in the list.phtml file:

$_product = Mage::getModel('catalog/product')->load($_product->getId());

All I had to do was set the Used in Product Listing field for the attributes I wanted to use on the category listing page to "Yes". Then I could remove this line and get the attribute data from the initial loading of the collection:

$_productCollection=$this->getLoadedProductCollection();
foreach ($_productCollection as $_product):

Apparently, because I had loaded the full model for each product, the price.phtml file was "depending" on it instead of the collection.

| improve this answer | |
0

This is a very very broad question.

  1. First of all, find out how much memory you have. If you are swapping to use virtual memory, then you are going to experience what could be perceived as a frozen site. If you are on shared hosting, give up now and switch to digital ocean with a 4gb virtual server.

  2. Second, if you have a significant amount of EAV attributes, then you should try enabling Flat Catalog Products, and Flat Catalog Categories.
    Note: Be sure that your EAV attributes are properly configured. You can experience issues with too many global attributes that have all the features enabled: ie: filterable, searchable, used in filtered navigation, enabled on frontend, used in advanced search.. etc.

  3. Too many products. Too many category-product associations. Too many attribute options ...

  4. Enable cache.

  5. There may be some third-party extensions that are adding to your demise..

  6. There may be conflicts or you could be loading collections and models with performance killing methods used, such as a collection that loads an individual model for each product in the collection. Set a collection pagesize(1) and currentpage(1) if you are using getFirstItem().. Don't use count($collection), instead use the method ->getSize()...

I could go on and on and on.. So many possibilities.

Resource: Performance Coding Issues1

| improve this answer | |
  • I would suggest reading the full question and revising your answer. – Michael Yaeger Nov 16 '16 at 4:09

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.