Magento Database Cleaning
Magento is an excellent platform, but it unfortunately falls short when it comes to having an efficient database. When selling a myriad of products, it’s a smart idea to have a sizable database. Managing the database by performing regular log cleanings can drastically improve the performance of your website along with its latency. The following is a walk through of how to tidy up a Magento database that has become over encumbered.
For starters, it is imperative that you make a back up of all your files prior to doing anything in case something goes wrong. You can either perform an export of your database using phpMyAdmin, or you can submit a technical support request so that we can do it for you.
Magento manages several logging tables. These tables make logs of things like which products have been compared, customer accesses and other ancillary logs. Magento has a self cleaning program to clean this out regularly, but this feature is inactive by default, and most consumers wont turn it on. Here are three ways to clean out these tables. You can either access the “Log Cleaning” feature in the Magento Admin, or you could just manually do so via phpMyAdmin.
The tables below are managed by the Magento Log Cleaning function:
log_customer log_visitor log_visitor_info log_url log_url_info log_quote report_viewed_product_index report_compared_product_index report_event catalog_compare_item
Log Cleaning through the Admin
- While in the Magento Admin click on System, then click configuration.
- In the menu on the left under Advanced click System.
- Where it says “Log Cleaning”, select yes to enable log cleaning, and configure the save your logs for 15 days. Then click save.
Manual Cleaning through phpMyAdmin
This is by far the most effective way to clean the logs for individuals that are more comfortable working with databases. It’s definitely quicker than the Magento tool, and it allows one to clean some of the tables that aren’t included in the Magento tool.
-Open the database in PhpMyAdmin in the cPanel Control Panel
-In the right frame, click on the boxes for the following tables:
dataflow_batch_export dataflow_batch_import log_customer log_quote log_summary log_summary_type log_url log_url_info log_visitor log_visitor_info log_visitor_online report_viewed_product_index report_compared_product_index report_event
Look to the bottom of the page, then click the drop down box that says “with selected” and click empty.
A confirmation screen will appear, click yes, and this will truncate all the tables you just selected
Note: It can be very easy to mistakenly delete a database instead of emptying it, you should be very careful and make sure that you are selecting the correct option.
Make sure you perform this regularly. We’ve seen a 3+ gigabyte database drop to less than 100 megabytes after proper log cleaning has been performed. This kind of maintenance is very important for the performance and health of your website and needs to be done periodically.
For an automated method to clean this up regularly, you can setup a cron job by following our instructions on our post about speeding up Magento commerce.
Instantly Speed Up Magento Commerce
This is a great way to improve the performance of your Magento hosting account and website, some users will immediately notice over a 5x speed increase! As some of you may or may not know, Magento has visitor logging and various other logs enabled by default. Eventually these logs will grow to a massive size and cause your website and the server to slow down.
Most web hosts include something like AWStats or you can use Google Analytics for advanced visitor tracking, so the logging Magento provides isn’t needed and isn’t very useful.
Why the Magento developers don’t have this disabled by default or cleared out regularly by default is way beyond me. I wish the Magento developers would realize how big of a performance factor this is and focus on increasing performance for us Magento users rather than continue to add more features and slow down the stores.
/end rant.
Enough Already - Just tell me how to do this!
1.) Download the file cleanup.php and upload it to your main Magento folder. Please note the file you are downloading is zipped so you will need to extract the file before uploading it. You only need to upload cleanup.php.
2.) Next you will need to login to your cPanel to setup a Cron Job. To do this just click on the ‘Cron Jobs’ icon under the Advanced tab in your cPanel account.
3.) Under the ‘Add New Cron Job‘ section select ‘Once a day‘ under the Common Settings drop down. After you have done that copy the following into the Command box:
curl -s -o /dev/null http://www.yourdomain.com/cleanup.php?clean=log
Make sure to change the bolded section of the code to where you uploaded the cleanup.php file to.
After doing so, click the Add New Cron Job button, and your done!
4.) If you would like to go a step further to increase your performance, while still in the cron job section you can add a new cron job to clean your var folder out.
Under Common Settings this time you can select 1st and 15th.
Add the following code to the command line:
curl -s -o /dev/null http://www.yourdomain.com/cleanup.php?clean=var
Again making sure to change the bolded selection to where the cleanup file is located, click Add New Cron Job, and again that cron will be saved and will run every 2 weeks. This one we extended a little farther apart since it doesn’t need to be ran as often.
If you have any questions or comments feel free to let us know under our blog comments section.
How To Setup Multiple Stores With Magento
Magento Multi-Store & Setting Up Multiple Magento Stores Using One Admin Area
If you want to setup multiple Magento stores and multiple domains that share the same admin area, the tutorial below will assist you in doing so. This is very useful if you have a lot of stores that share the same or related products and you wish to manage it from one central location. You will also be able to track your sales and customers without having to login to the admin area of each website.
With the latest release of Magento Commerce it is much easier to set this up than it was in previous versions. Before it required you to modify the index.php file to handle your different domains pointing at different stores and various other complicated modifications. With Magento 1.4.x it is now much easier. The new index php contains the following code:
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
It checks two variables(code & type) and then uses them to run Magento. With the new code you’re able to set which store is supposed to be running under your main domain directly within your virtual host definition(root access required) or for our shared hosting and cPanel hosting customers you can actually now use .htaccess to accomplish this.
Creating your additional stores
If you haven’t already done so, the first thing you will need to do is setup your second store in the Magento admin area:
- Login to the Magento admin area.
- Go to the Catalog tab, then select Manage Categories.
- Click the ‘Add Root Category’ button on the left.
- On the right, for the Name, enter your secondwebsite.com. In the dropdown set Yes for both ‘Is Active’ and ‘Is Anchor’.
- Click on ‘Save Category’.
- Next you should go to the ‘System’ tab and select ‘Manage Stores’.
- Click the ‘Create Website’ button.
- For the Name enter your Secondwebsite.com, and for the ‘Code’ you should enter secondwebsite. You’ll be using this value later so make sure your note it down somewhere.
- Click ‘Save Website’.
- In the same area, click on the ‘Create Store’ button.
- For the Website, select your Secondwebsite.com from the dropdown. For the ‘Name’, you can enter Secondary Store. For the Root Category, select your now created Secondwebsite.com from the dropdown.
- Click the ‘Save Store’ button.
- Next click on the ‘Create Store View’ button.
- For the ‘Store’, select Secondary Store from the dropdown menu, make sure it’s for the created Secondwebsite.com. For the Name, you can enter English. For the ‘Code’, you should enter secondwebsite_en. For the Status, select ‘Enabled’ from the dropdown menu.
- Click on ‘Save Store View’.
- Next you will need to go to the ‘System’ tab and select ‘Configuration’
- For ‘Current Configuration Scope’ (located near the top left), change the dropdown menu from ‘Default Config’ to Secondwebsite.com.
- Select ‘Web’ from the left sidebar under the ‘Genera’l headline.
- For both the Unsecure and Secure sections, uncheck the Use default box next to the Base URL item, and enter the URL for your store, e.g. secondwebsite.com. Make sure to include the trailing backslash.
- Click the ‘Save Config’ button.
You’re almost done so hang in there!
Once you are finished creating the store, if you have not added your second domain as an add-on domain you will need to login to your cPanel account with us and create it as an Add-on domain now. Once you have done this you then need to copy your index.php and .htaccess file to the created directory for your add-on domain.
After copying over your index.php file, you should replace the following lines of code in the index.php file located only in the new add-on directory:
Replace this line:
$mageFilename = ‘app/Mage.php’;
With the following:
$mageFilename = ‘../public_html/app/Mage.php’;
Next you will need to either use the VirtualHost method(VPS and dedicated servers) or the .htacess method (for regular magento hosting / shared hosting accounts).
Using VirtualHost:
To set this up using the Virtualhost method you should simply add the following lines within your VirtualHost definition file:
SetEnv MAGE_RUN_CODE "base" #Put your main/base website or store code here.
SetEnv MAGE_RUN_TYPE "secondwebsite" #Here you should put 'secondwebsite' if the URL of the additional store you are adding is secondwebsite.com.
Using the .htaccess method:
If you do not have access to the virtual host file and are not a VPS or dedicated server customer, you can still use .htaccess for this.
In your .htaccess code you will need to define your main and secondary websites. For example if the URL of your main/base website is base.com and the URL of your second website is secondwebsite.com you should put the following code in your .htaccess
SetEnvIf Host .*base.* MAGE_RUN_CODE="base";
SetEnvIf Host .*secondwebsite.* MAGE_RUN_TYPE="secondwebsite";
You are, of course, not limited to using just 2 websites. To add additional stores you would simply add the additional lines of necessary code:
SetEnvIf Host .*thirdwebsite.* MAGE_RUN_TYPE="thirdwebsite";
etc.
You should now be all setup using Magento multi-stores and have multiple stores with one main admin area in Magento, without messing around with the code and the other previous lengthy methods
.
If you have any questions, additions or issues with this feel free to comment.
Magento 1.7 Released
Magento Enterprise Edition Version 1.7 was recently announced. The new release features enhancements and new functionality focusing on enhancing customer loyalty through a reward points system, performance enhancement through full page caching and many other key administrative functionality improvements.
New Features in Enterprise Edition Version 1.7
Magento Enterprise Edition version 1.7 features the all new reward points system, which allows merchants to implement unique programs designed to enhance user experience and increase customer loyalty. Points are awarded based on purchases, as well as actions such as registering on the site, inviting others to register, submitting product reviews and tags and more. Points are managed by customers through their account and are redeemable at checkout time towards the price of a purchase.
Magento Enterprise Edition version 1.7 also places a focus on highly tuned page performance by making use of Full Page Caching. Forrester Research has recently hailed caching as the “best practice” behind some of the internet’s fastest sites and new performance optimizations included in this version of Magento Enterprise Edition provide significant benefits for merchants of all sizes through a new Full Page Caching module. The optimizations, which together with other performance-enhancing functionality already in Magento, significantly reduce page load times, increase conversions, and enhance the customer browsing experience.
Additionally, Magento Enterprise Edition version 1.7 included no less than fifteen new features available to store administrator users to help augment the range of tools administrators have at their disposal for managing their site. These include such features as sales report optimization, WYSIWYG Editing for Products, Categories, and email templates, Design Theme & Packages Facilitation, Custom Variables for use in email templates and CMS, and upgrades to the Magento Enterprise Edition CMS+ content management engine.
Magento Hosting For Enterprise Edition
In addition to our regular optimized web hosting services, all eLief VPS and dedicated servers can be optimized for Magento hosting – with our expertise and experience with Magento we can customize a solution based on your exact needs, number of products and SKU’s in your store, growth expectations and much more. Contact us today for a free quote.
All hosting blogs are not created equal.
A blog from eLief? Does the world really need another blog? We think so. Let me tell you why – eLief is at the epicenter of an exciting transformation in the hosting industry. Did you know your average hosting company is still using the same technology that was around 10 years ago? Not here. eLief runs state of the art technology using LiteSpeed web server. LiteSpeed is an advanced web server that processes pages up to 8x faster, reduces server loads for better performance with less CPU and memory consumption, and also allows us to perform servers updates, maintenance, and restarts without downtime. We are here to revolutionize the industry and you will only continue to see more big things coming from us. LiteSpeed hosting is just the beginning.
Ok cool, so what..you created this blog just to talk about your services? Not exactly! This blog will serve as a great way to communicate and interact with our readers and customers, gather opinions, collaborate with industry veterans, or to just come and read the mindless ramblings from the creators of eLief.
The scoop you can get from here:
- Upcoming news and insider perspectives
- New feature announcements
- How-to tutorials
- Webmaster tips & techniques.
- In-depth information about what happens behind the scenes at eLief.
- Why eLief is the best hosting company in the galaxy and how it will come to rule the world. Just kidding, no but seriously.
To start things off, during the month of April, we will be focusing on tutorials and information about running a Magento Commerce store for all our magento hosting and ecommerce customers.
