10 Tech Tips for Magento Store Owners
1. Use hosting service, which allows access via SSH
SSH is the protocol, which enables access to server allowing remote execution of the commands in a server.
Having SSH access, it is possible to efficiently solve a great deal of different tasks related to technical maintenance of the Magento store. Next, we will list new and exciting opportunities you can take advantage of. We strongly recommend to use such a hosting service for online store that provides SSH access.
At that, it is important to take into account the fact that many shared hosting providers formally provide quite limited SSH access, which does not allow to perform basic operations. Therefore, it is necessary to clarify this issue in advance. Do not forget to check whether it would be possible to execute such commands as crontab, git, mysql, mysqldump via SSH.
2. Use GIT
Many internet stores save history of the source code changes in their backups. When at some point some coding error appears, which is not so easy to deal with, it is possible to reverse the situation back to the previous backup or even by few backups away. Such an approach is extremely inefficient to go on with, and it does not ensure stable functioning of the store. First, one needs to spend a lot of time to locate necessary backup and make recovery. Second, quite often store will be temporarily closed before all the works are completed.
We strongly recommend to all the Magento store owners to use GIT for saving all the source code changes. Documentation describes all features of this system. We will try to explain our approach to the use of GIT for the purpose of maintaining the Magento store in separate blog post.
3. Create separate host for testing
We often face the fact that all file changes are done directly in live host. New modules are also installed directly to the live host. It is obvious that this is a very risky approach to go with. Each small error can cause interruptions in the work of the internet store.
We recommend to create test host (for instance, test.store.com), copy all files into it, and connect the host to the test database, which should also serve as a copy of the main database.
You should make all the source code modifications, installation of the new modules, and updates using this test host. Once done with that all, you should check very thoroughly how your store works. Only when you are certainly positive that there are no any obvious problems were left unfixed, you can transfer new functionality to the live host.
You can manually transfer updated files, but it is better to use GIT for this purpose.
4. Make sure that there won’t be any changes done with the files of the Magento core
It is not recommended to make any changes in the files of the Magento core due to the following reasons:
- Magento code is quite complex and you may unintentionally cause some bug in the core, which will be very hard to locate and fix.
- It is quite probable that there will be problems with the work of the 3rd party modules, which use the core functionality.
- All the core changes will be rewrited once Magento is updated and they will have to be recovered or redone.
Store owner should ensure that hired developers and 3rd party module developers do not introduce any changes to the core files. It can be done via GIT. Before adding new changes into repository, you need to execute the command git status in order to see the list of all modified files. You have to make sure that there are no changed files present in the following folders:
If there are such files, then it is necessary to request recovery of initial Magento files from the developer. In this case, he has to locate modified files in the folder app/code/local.
5. Use the command mysqldump to dump the database
Many of our clients use the phpMyAdmin or other web applications for creation of database backup. At that, they experience many different problems such as follows: dumps are not complete or they do not include foreing keys. Using these instruments, it is only possible to create such a dump only if the size of database is comparatively small.
We recommend to use the command mysqldump to create the backup of Magento store database. To create backup, you have to execute this command via SSH as follows:
mysqldump -u user_name -p database_name > dumpfile.sql
You have enter your values such as user_name and database_name in this command. You can request them from your hosting provider or opening the file: app/etc/local.xml. Use of this command will result in creation of the file with dump: dumpfile.sql .
To recover data from the file with dump, you have to execute the following command:
mysql -u user_name -p database_name < dumpfile.sql
Be careful, this command will substitute all the data in database by the backup data.
6. Do not work using root user
Some Magento store owners have own dedicated or virtual servers. They quite often execute all commands logging as a root user. For instance, they edit the files and install the modules.
It is better not to do so as it is very unsafe choice to go with. Many bugs appear due to problems with the access rights for the store files.
We recommend to contact administrator of your server and ask him to set up your rights for the magento files so that you would be able to execute all necessary operations under usual username (not as a root user). You have to use root access only when it is really necessary.
7. Monitor content of the log files
Check regularly content of the log files upon completion of installation and testing of the new module. These files are located in the following folder: /[magento_root]/var/log. As a rule, these files contain messages about the errors. If you see new messages then most likely new module is a culprit. We advise you to find out the cause of their appearance. It is quite possible that module has an error in it, which should be corrected.
We also recommend to check sometimes the log files in the live host. You can detect some errors, which do not show themselves in the test host (for instance, the error that appears during the work with payment system) and which need to be fixed.
Try to restrain from substantial increase in the size of log files. Big log files are hard to check and analyze. Too large files can occupy too much free space in the hard drive.
8. Try not to install the modules with the encoded code
Paid Magento modules sometimes can have encoded initial code. Using such a strategy, developers of these modules are trying to secure themselves from illegal use of their code.
However, from the store owner’s point of view, such modules have a series of substantial disadvantages:
- First, it is necessary to install special software to make the modules work. Such software can be quite hard to install.
- It is also not so easy to manage the project using test or local server
- It is very hard to locate and fix the bugs in case of their appearance
- It is not possible to customize the functionality of such module
Therefore, we recommend to use such modules only if initial code is open. There are many such modules being sold in the market and they are often sufficient to ensure complete functionality of the store.
9. Create backups of modified 3rd party files
Sometimes it is necessary to slightly modify the 3rd party developer’s module so that it would work as required. The best option is to create own module and rewrite necessary classes, but it’s not easy way. So very often developers edit one or two 3rd party files.
If you plan to update modified module in the future then we recommend to create copies of the modified files with additional extension .MODIF right upon completion of such edits. All the modified lines should be commented.
Let us assume that there is the following file: app/code/local/Mirasvit/Rma/Model/Rma.php. We decided to modify this file. In this case, we have to create its copy app/code/local/Mirasvit/Rma/Model/Rma.php.MODIF. Once the module is updated, we can recover our comments using the file with extension .MODIF.
10. Make sure that there are no additional files in the Magento root
Quite often, many unnecessary files tend to accumulate in the Magento root. Sometimes, it is different test files. But sometimes it happens so that backup or log files end up in there.
Such situation is not safe. Hackers can scan your website, find these files and it can end up very badly.
To avoid such a problem, we advise to check the root directory of Magento and remove all unnecessary files, which are sometimes forgotten by the developers. In the root directory, you should only keep these files, which are supplied in standard Magento package.