<?php $categories = $_product->getCategoryIds(); ?>
<?php foreach($categories as $k => $_category_id): ?>
<?php $_category = Mage::getModel(‘catalog/category’)->load($_category_id) ?>
<a href=”<?php echo $_category->getUrl() ?>”><?php echo $_category->getName() ?></a>
<?php endforeach; ?>
Magento is slow. Seriously now, Magento is so slow that the Magento team is always going through great lengths to help store owners and hosting providers improve the overall performance of the Magento shopping cart application. There are numerous guides out there and rumors has it that Magento is readying another official best practices white paper with more up to date info. While most performance tips require deep knowledge of server management or coding experiences, I wanted to share with you 7 Magento performance tips that are easy to set from the Admin Panel. Let me know what you think and what ultimately worked for you! Most Magento developers are unaware that there is an extended mechanism for logging within Magento and that it is turned on by default. This logging mechanism was once set to be on by default and therefore, setting it off in the next release can potentially break havoc across the tens of thousands of Magento websites or extensions out there. It will probably won’t affect as many sites as one would think but this is the answer I got from Magento’s chief architect, and is a solid consideration for such software with the large base of installations as Magento. So, what can you do about it? simple: turn it off.
In the Magento Admin Panel go to “System” > “Configuration”, from the left panel choose “Advanced” from the “Advanced” Panel at the bottom left. Look for the module “Mage_Log” and set it to ‘disable’ and save. Compilation is a new feature in Magento version 1.4.x.x and above. This feature actually existed as beta and was turned off by default in previous versions of Magento but from version 1.4.x.x and on it is now turned on by default and ready for production. This new feature compiles files and scopes into more easily accessible blocks of HTML. According to the Magento Core team, using this feature provides “between 25% to 50% better performance depending on the page requested.” To enable, go in the Magento Admin Panel to “System” > “Tools” > “Compilation” and click on the “Run Compilation Process” button. Combining files feature is now built in by default in Magento version 1.4 and above. Notice that in some versions this is still in beta and it does not compress or minify the files, only combines them. In any case, this is a great features for performance and always shows significant improvement in the browser rendering time.
To turn this on, go in the Magento Admin Panel to “System” > “Configuration”, from the left navigation panel, click on “Developer” link from the “Advance” panel (all the way at the bottom). Look for the two tabs “Javascript Settings” and “CSS Settings” and you want to select “Yes” for the Merge files options in both. If you need additional horse power you may want to look at Fooman speedster extension which merges and compresses Javascript and CSS files on the fly. The Fooman extension also uses advanced caching mechanism for the compressed files and has more options to tweak for the more advanced store owners out there. Magento inherently uses the EAV database module. This means that each product or category has information spread throughout dozens of tables.
Every time that a product page is requested or a category page is requested a big join query is made to gather all these pieces of information and build the product object. While extremely flexible this feature is a huge bottleneck for performance – this is where the flat catalog comes handy. The flat catalog essentially allows Magento to build the same objects with one single DB query from one single DB table. To turn this feature on, go in the Magento Admin Panel to “System” > “Configuration”, choose “Catalog” from the “Catalog” panel. Expand the top panel which should say “Frontend” and at the bottom you should see two options “Use Flat Catalog Product” and “Use Flat Catalog Category”. Set both to Yes. Note: if these options are grayed out, you probably need to enable indexing for these features (In the “System” > “Index Management” page). Layered Navigation is actually a great feature for shopping carts with a large catalog.
It helps your users find the right product by narrowing down the product attributes it wishes to buy. These feature unfortunately slows down Magento significantly, hence if you do not use it or understand what it is, go ahead and disable it until you are ready. In order to disable this feature, set the attribute ‘Anchor Category’ to ‘No’ for all your categories. This tip is trivial, but I often see this mistake been made by existing store owners. To install a new Magento extension is so easy these days, that many simply go for it and try out a variety of extensions. The problem is that the vast majority of these extensions may not be programmed with performance in mind, hence they are a hindrance on the site performance. Even worst, some extensions may introduce security wholes that you may never know about until it is too late.
Hence, it is always a safe practice to use as little extensions as you need and never leave any extension just because you never had the time to remove it. Less extensions also means easier upgrades, which is my next performance tip. Another trivial performance tip that many store owners skip for the sake of adding features or lack of resources is upgrading often. Magento is still in its infancy as a shopping cart platform and there are tons of features that are now being discussed and added into the core code. In the last 12 months the Magento Core team has been putting a lot of effort in closing bugs and adding performance enhancements, like the flat catalogs, caching & indexing mechanisms, and now the compilation mechanism. So, if there is a new stable version available out there you should focus on upgrading your core platform and learn in what new ways you will be able to boost performance, and most importantly sales! This list is by no means a comprehensive list of performance tips, but it serves well anyone who wishes to tune up their Magento website without help from a developer or your hosting provider. All these tips can be performed easily from the Magento Admin Panel. If you need additional assistance with your Magento shopping cart, see our Magento Services and our Magento Extensions pages.