Virtuemart Site slow with Manufacturer Searchmodule
Written by Thomas Kahl
Monday, 28 February 2011 13:19
Just a short tip if you have problems with a high MySQL-Serverload in your Virtuemart shop. If you have a large number of products and the manufactuter searchmodule activated (mod_virtuemart_manufacturers), it may be that searchengines are "killing" your database by submitting the manufacturers searchform without selecting a manufacturer.
Virtuemart then searches all products (like with "list all products") using the shop_browse_queries.php. If you have a lot of products (>10000) or categories (>500), this might lead to queries the produce "temptables on disk". This happens, when MySQL cannot handle the query in the cache / memory. This is one of the worst things that could happen - because it is extremely slow and it will lead to waiting queries in the queue. You can find out if your database produces these queries when you open the Process-List in phpMyAdmin. The list shows you the status of the queries and the time they need for execution.
What we have done to avoid this is that we check for a "valid" manufacturer search.
Edit /modules/mod_virtuemart_manufacturers/mod_virtuemart_manufacturers.php and add a hidden field to the form - like this:
Then edit the file /administrator/components/com_virtuemart/html/shop_browse_queries.php and add some code at the end of the file to check if the manufacturers search is called and if there is an ID:
// VMXHack Start - Disable search for empty Manufacturer field if(JRequest::getInt('CheckMFsearch') && !JRequest::getInt('manufacturer_id')) { $list=$count=""; echo '<h3>Please select a manufacturer for your search!</h3>'; } // VMXHack End
Now the query is resetted and an information is shown for the user. This will avoid unwanted large and complex queries. Without this change (and some more optimization), a shop of one of our support-ticket-customers was nearly unusable when searchengines were on the site.
VM-Expert.com is part of the B01 Consulting Network. Since 2003 we build shops and websites with Joomla and Virtuemart. We are specialised in developing custom Joomla and Virtuemart Extensions.