0

On the main page of the site, there is a module of the goods slider. The module uses the query:

$list = $this->_getProducts();

Because of what the page is loaded 5 - 6 seconds. Is there any way to optimize this query?

1

Since I can't comment yet I will post it as a solution, it would be good to see what the function _getProducts() does assuming it's a module defined function.
If it does some recursive calls you could potentially change it or even make it an AJAX call so it won't intervene at all.

If anything else, you can select the products of a specific category using:

Mage::getModel('catalog/category')->load($category_id)->getProductCollection();

Tho, 5-6 second for a query is REALLY slow, is it trying to do mulitple joints and likes?

  • I try to make a request: $category_id = '3'; Mage::getModel('catalog/category')->load($category_id)->getProductCollection(); But at the same time the site does not load at all (( – Eva_m Aug 22 '17 at 8:37
  • Did you check what the _getProducts() function did first? Since it would be the easiest to fix the problem at it's core. Also are there any errors, does the page return 500? What do system.log and exception.log say? – AngelsDustz Aug 22 '17 at 9:06
  • Need to find out what the function does? Or what kind of query does it create? With it, the slider gets information. – Eva_m Aug 22 '17 at 12:17
  • Well in this case it is important to know what the function does, if the function calls 5 queries instead of 1 you could reduce it to a single query. How ever, if the function does a single call and it is optimized already you could look at alternative ways to get the data needed. – AngelsDustz Aug 22 '17 at 12:32
  • Hmm ... Now I'll try to find out what this query is doing. – Eva_m Aug 22 '17 at 12:42

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.