Here are a few tips to take into account if you want to start developing with Magento.

On the backend

Go to System » Configuration and click on the Advanced » Configuration tab. There you should enable the profiler (debug tab) and also the log (log settings tab). Remember that the /var directory has to have writing permissions.

Developer Mode

Enable the developer mode in htaccess (or your vhost configuration). If you want to develop on Magento you have to enable the developer mode. Just add the following line to your .htaccess file (or vhost configuration)

#Magento Developer Mode
SetEnv MAGE_IS_DEVELOPER_MODE "true"
  • Edit the index.php file

Next step is to edit the index.php file in order to enable the Varien Profiler and also display errors. Your index.php file should look like this:

Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
Mage::setIsDeveloperMode(true);
}

ini_set('display_errors', 1);

MySQL performance

When it comes to performance we always need to know which queries in Magento are taking more time to execute. It is possible to log all the queries and also show (along with the profiler) how long it took to load the page, how long was the longest query (in  time) and the longest query itself. In order to enable this, do the following:

  • Modify: lib/Varien/Db/Adapter/Pdo/Mysql.php and set to true: $_debug, $_logCallStack and set to “0” the $_logQueryTime value.
  • Create a writable directory in var called debug (that is, var/debug) in your magento directory.

Once you do this. At the bottom of each loaded page in Magento you’ll see the profiler and also the mysql data. You can also find a file called pdo_mysql.log with all the queries that have been executed during the page loading. You can also watch this file and see in live mode which queries are being executed and see the time each query needs to do its work.

Useful extensions

Install a couple of useful extensions. There are many extensions to help developers. Not all of them work in all Magento versions. Up to now I’ve found two extensions that are free and compatible up to Magento CE 1.6 and EE 1.11.

  • Wee_developertoolbar | It adds a tool button at the top-right corner of our website showing some basic information. Clicking there we’ll be able to see information about blocks, mysql queries, clearing the cache, enable translation, block hints, etc. It’s the greatest extension for developers I’ve found up to this moment

  • Layout analyzer | This extensions allows us to see what’s the final layout that has been loaded on our page. The most interesting thing is that we can take a look at the final xml layout that has been used to load the page.

Conclusion

With all this you should have all the tools you need to start developing on Magento and be able to debug properly. Magento is somewhat hard sometimes, so it’s important to have all the available debugging and developing tools with us.


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.