Magento Tips

  • Remove Trailing Slash From Magento URLs – SEO Duplicate Content Issue

    Because of SEO reasons, a common problem that Magento has is that it indexes two URLs of the same page which causes issues with duplicate content when it comes to Google crawling.
    For example it will index both of these URLs.

    Ideally, we want Magento adding trailing slashes to the end of the URLs and then redirect it to the page without the trailing slash, and here’s how.

    Let's get started

    To start with we need to edit the getURL() method to stop it generating URLs with trailing slashes, so copy the following file from:

    Now open Abstract.php and find the following line of code:

    return $this->_getUrlModel()->getUrl($route, $params);

    Replace that line with the following:

    $return_url = $this->_getUrlModel()->getUrl($route, $params);

    if ($return_url != $this->getBaseUrl() && substr($return_url, -1) == '/' && !Mage::getSingleton('admin/session')->isLoggedIn()):

    return substr($return_url, 0, -1);


    return $return_url;


    Now copy the file app/code/core/Mage/Core/Model/Url.php
    Once you’ve done that open it and find the following code:

    if ($noSid !== true) {



    Change ($noSid !== true) to ($noSid == false)

    Edit your .HTACCESS file

    Find the following line of code:

    RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    Add the following immediately underneath it:
    RewriteCond %{request_method} ^GET$
    RewriteCond %{REQUEST_URI} !^/downloader.*$
    RewriteCond %{REQUEST_URI} ^(.+)/$
    RewriteRule ^(.+)$ %1 [L,R=301]

  • Magento - How to fix Php 5.6 deprecated messages

    Magento officially doesn't support Php 5.6. But you know, the latest version of Php (right now 5.6.1) comes with a lots of new features and optimizations, which could be handy.

    But those nasty deprecated messages “Deprecated functionality: iconv_set_encoding(): Use of iconv.internal_encoding is deprecated” fills Magento’s logs, right?

    Temporarily, we simply just have to override some core files of Magento (well, they are core Zend Framework files).

    Here are the steps to follow:
    1. Create the following folders:

    2. Copy the following files from /lib/Zend/ to /app/code/local/Zend/:

    3. Open the files from /app/code/local/Zend/ in a text editor and search for “internal_encoding” and replace them with “default_charset”.

    Before doing this, make sure that the “internal_encoding” string is a parameter of an iconv related function. Don’t replace “mb_internal_encoding”, “$internal_encoding” or any other non iconv related stuff, because code will be broke.

    This solution is for Magento 1.8, but it should be very similar for 1.9 as well. If you are not sure, just search in all files for “internal_encoding” and do the three steps above for the needed files.

    Hope this would be help!

  • Make faster Magento ecommerce: Performance & Hosting Tips for Better Conversion

    Enable Cache Management in the Magento Admin Panel

    Enable Cache Management in the Magento Admin Panel

    First thing you should always do before going live — enable cache management! This is good way to improve Magento performance. Go to System > Cache Management and enable each cache type. Just make sure when you update your system to flush the cache so you can see your changes.

    Enable JavaScript and CSS Combining in the Magento Admin Panel

    Enable JavaScript and CSS Combining

    Another easy configuration setting located in System > Configuration under Advanced > Developer. Merge your JavaScript and CSS files to save on initial loading time when the customer first visits your site. Without this your customers will have to download each JS/CSS file one-by-one. Reduce the number of HTTP requests dramatically by using this option. In Avalanche, we cut down our JS requests to 2 files on the homepage and 1 CSS file.

    Install Fooman Speedster via Magento Connect (Free)

    Install Fooman Speedster via Magento Connect

    This free extension from Fooman will minify your JavaScript and CSS files using the PHP minify library. It also compresses your code and provides automatic versioning. To install, click here to get your extension key for Fooman Speedster. You’ll then need to log in to your Magento admin panel. Go to System > Magento Connect > Magento Connect Manager. Add the extension key and install the extension. You may have to update your folder write permissions via SSH in your Magento install directory. Refer to thisMagento Connect permissions guide for more information.

    After installing, your files should be minified instantly. Go ahead and check your combined scripts to see Fooman Speedster in action.

    Install HTML Minification by Jemoon via Magento Connect (Free)

    Install HTML Minification by Jemoon via Magento Connect

    Although this extension is still in beta, I haven’t experienced any issues with it. HTML Minification by Jemoon is straightforward and easy to set up. Get your extension key for HTML Minification here. Follow the same instructions as Fooman Speedster. Make sure you allow beta extensions in your settings tab. Your HTML files should automatically be minified! It’s that easy.

    Optimize Your .htaccess File for Max Performance

    There’s a lot of optimization techniques you can use to dramatically increase Magento performance via your .htaccess configuration. Here’s a comprehensive list:

    Enable Gzip Compression

    # Force deflate for mangled headers
    SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s,?\s(gzip|deflate)?|X{4,13}|~{4,13}|-{4,13})$
    RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  change=yes;byteranges=no


    Use Expires Headers for Better Cache Control

    “Entity tags (ETags) are a mechanism web servers and the browser use to determine whether a component in the browser’s cache matches one on the origin server. Since ETags are typically constructed using attributes that make them unique to a specific server hosting a site, the tags will not match when a browser gets the original component from one server and later tries to validate that component on a different server.”

     ExpiresActive on
    # Perhaps better to whitelist expires rules? Perhaps.
    ExpiresDefault                          "access plus 1 month"
    # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
    ExpiresByType text/cache-manifest       "access plus 0 seconds"
    # Your document html
    ExpiresByType text/html                 "access plus 0 seconds"
    # Data
    ExpiresByType text/xml                  "access plus 0 seconds"
    ExpiresByType application/xml           "access plus 0 seconds"
    ExpiresByType application/json          "access plus 0 seconds"
    # RSS feed
    ExpiresByType application/rss+xml       "access plus 1 hour"
    # Favicon (cannot be renamed)
    ExpiresByType image/x-icon              "access plus 1 week"
    # Media: images, video, audio
    ExpiresByType image/gif                 "access plus 1 month"
    ExpiresByType image/png                 "access plus 1 month"
    ExpiresByType image/jpg                 "access plus 1 month"
    ExpiresByType image/jpeg                "access plus 1 month"
    ExpiresByType video/ogg                 "access plus 1 month"
    ExpiresByType audio/ogg                 "access plus 1 month"
    ExpiresByType video/mp4                 "access plus 1 month"
    ExpiresByType video/webm                "access plus 1 month"
    # HTC files  (css3pie)
    ExpiresByType text/x-component          "access plus 1 month"
    # Webfonts
    ExpiresByType font/truetype             "access plus 1 month"
    ExpiresByType font/opentype             "access plus 1 month"
    ExpiresByType application/x-font-woff   "access plus 1 month"
    ExpiresByType image/svg+xml             "access plus 1 month"
    ExpiresByType application/ "access plus 1 month"
    # CSS and JavaScript
    ExpiresByType text/css                  "access plus 1 year"
    ExpiresByType application/javascript    "access plus 1 year"
    ExpiresByType text/javascript           "access plus 1 year"
    Header append Cache-Control "public"
    // ]]>

    Remove Unncessary JavaScript Files in Your Magento Layout XML Files

    There’s a lot of JavaScript bloat in Magento. You can safely remove certain files and improve performance. Here’s a sample from Avalanche’s page.xml layout file:

     I commented out all of the Scriptaculous code and translate.js. Menu.js was also removed for custom jQuery code. 

    Install APC, Eaccelerator or Xcache on Your Server

    This one is more difficult — you’ll need SSH access to install one of these on your server. These cache systems make PHP more responsive by caching your PHP code, stopping the interpreter from recompiling code upon every request. I’ve used APC in the past and have had mixed results using it with Magento, but try it out and see if your page performance increases.

    If you’re wondering which one to use, check out APC vs. Eaccelerator vs. Xcache on StackOverflow.

    If you want to install APC on an Ubuntu server, this is the approach I use.

    Move jQuery & Custom JavaScript Code to the Footer

    If you’re using jQuery (hopefully you are) and custom code, you’ll definitely want to include those files at the bottom just above your ending body tag. This way your website will render on the screen faster and not have to wait for these additional JS files to load. Learn more about JS footer code here.

    Use Amazon S3 for Image Hosting & Install OnePica_ImageCDN via Magento Connect (Free)

    Amazon S3 is a cost-efficient way to serve product photos in your Magento store. It’s very inexpensive and quick to set up. Luckily there’s a free Magento extension that lets you hook up your Amazon S3 bucket. Using OnePica_ImageCDN makes it easy to set up your own CDN server for images using Amazon S3. Why should you use Amazon S3/CDN?

    Design CSS Sprites to Reduce HTTP Requests

    Here’s another standard front-end optimization: Group your CSS background images into sprites. The browser downloads the images used in your CSS when your CSS file is loaded, slowing down render speed. A sprite can include as many images as you want in a single file. Typically I group rating stars and button states into their own unique sprites instead of having separate images for each state or rating, e.g. button_hover.gif, button_active.gif or rating_1.gif, rating_2.gif. However, it gets kinda tricky. If you have repeat-x or repeat-y backgrounds you can’t place them together in one sprite. When you build sprites you’re using overflow: hidden in your CSS and cutting off part of the sprite to only show one piece of the sprite. To learn more about CSS sprites, click here.

    Testing Your Magento Theme Speed

    Testing Your Magento Theme Speed

    If you want to see how fast your magento theme is performing in the front-end, use Developer Tools in Chrome or Firebug for Firefox. Install the YSlow extension/add-on.

    Hopefully our tips is helpful! If you have any questions don’t hesitate to contact us

  • Enable Template Path Hints for Frontend & Admin Panel in Magento

    In magento, the html on any page comes from many different phtml files. So if you want to make a change in any page, you need to first know from where that html code is generated. To know this, you need to enable template path hints from magento.


    Continue reading

  • Speed Optimize Magento for Developer Machine Windows

    Summary:  optimize Magento for a local Windows developer machine

    We've optimized Magento for a local Windows machine and reached speeds increasements of 400% (4 times) till 3000~1500% (15 to 30 times). The screen below shows the speed measurements.

    After optimization the average load of a Magento page is 1.0 seconds till 1.53 seconds. Below 12 steps have been detailed out to optimize your own Magento.

    Wampserver + magento speed optimization on windows


    1.     Added APC cache and optimized for Magento.
    2.     Disabled Xdebug extension.
    3.     Changed memory limit of PHP to 512MB
    4.     Unloaded Apache extensions not used, also unload PHP Extensions.
    5.     Disabled firewall and antivirus.
    6.     Tweak thread and memory settings of Apache.
    7.     Enable gzip compression with .htaccess
    8.     Moved .htaccess to vhost file, and Allow Options None in documentroot.
    9.     Enabled in Magento backend (System > Configuration > Advanced > Developers > Css merge)
    10.  Enabled Javascript compression
    11.  Enable Magento compiler (will compile all files to /includes/src ~ System > Tools > Compiler)
    12.  Use IPv4 only

    Continue reading

  • Magento xdebug with Netbeans


    Magento xdebug with Netbeans 7.3.1 and wampserver.

    Taking the pain to have a debugger working is worth the effort. I will take you through setting up debugging with xDebugger on Netbeans and windows and wampserver in 14 steps. This how to debug with Magento using Netbeans and xdebugger tutorial is written for Windows, but in general it can be used for any operating system such as Linux or Mac OS.

    1. Install wampserver (latest preferable 32 bit). Wampserver already includes the xdebugger extension.
    2. Install Netbeans. Netbeans works well with local or remote debugging.
    3. Configure xdebug to work
    4. My php.ini xdebug configuration looks like

    Continue reading

  • Installing & Configuring APC cache for Magento


    APC (Alternative PHP cache) is a free opcode cache for PHP, which optimizes PHP intermediate code.. APC engine caches the compiled bytecode of PHP scripts to avoid the overhead of parsing and compiling source code on each request. It stores PHP pages in RAM and reduces hard disk activity. You should be able to achieve a 50% increase in system capacity and your CPU will be 50% less busy.


    Magento stores its cache data in the file system by default. This is fine for small sites with low traffic. As you get more and more traffic and HTTP requests, file system reading and writing will become slower.

    This guide is for Windows only. But for Linux based operating systems, the configuration of APC procedure would be just a little bit different.

    Continue reading

  • Magento checkout page very slow - fixed (Magento 1.4, 1.5, 1.6 , 1.7)


    When customers place an order (during the final stage)? IT’S SO SLOW Load your checkout page in less than 1 second. USE DRAGONFROOT CHECKOUT SPEED OPTIMIZER

    The found workaround is to disable some observers from Mage_Downloadable and Mage_Rss, who execute in afterSave of each item in order.

    Since I don’t use downloadables or the RSS feed, it was a simple fix to go find the respective module’s control files in app/etc/modules and set the line to false. The one for RSS is in Mage_All.xml and the other is in Mage_Downloadable.xml if I remember right. Modules don’t load, observers go to sleep so they aren’t firing for every line item in the cart. Overhead goes away.

    Continue reading

  • Magento Controller Dispatch and Hello World

    The Model-View-Controller (MVC) architecture traces its origins back to the Smalltalk Programming language and Xerox Parc. Since then there have been many systems that describe their architecture as MVC. Each system is slightly different, but all have the goal of separating data access, business logic and user-interface code from one another.
    Continue reading

  • The Magento Config

    The config is the beating heart of the Magento System. It describe, in whole, almost any module/model/class/template/etc than you’ll need to access. It’s a level of abstraction that most PHP developers aren’t used to working with, and while it adds development time in the form of confusion and head scratching, it also allows you an unprecedented amount of flexibility as far as overriding default system behaviors go.
    Continue reading

10 Item(s)

per page
My Cart