August 01, 2011

Updating an Old Theme to Work With Magento

Many Magento store owners continue to operate old versions of the rapidly maturing e-commerce application. With the 1.6 release looming on the horizon, now seems like a good time to consider upgrading. If you’re running a version prior to the 1.4 release, you will need to make some changes to your theme in order for it to be compatible with newer versions. While the extent of these changes depends on the customizations you have performed, there are a few that we have run into consistently, and therefore apply them every time we perform an upgrade on an older store.

Changes to page.xml

Two changes to the stock page.xml file need to happen whenever you upgrade from a 1.3 release. First, you need to add a new javascript for credit card validation. Second, you need to add a “name” attribute to the core/profiler block.

To add the new javascript file:

  1. Open the page.xml file located in your theme’s layout directory using your favorite editor.
  2. Locate the “page/html_head” block near the top. You’ll see a list of nodes like the following:

    [code]<action method="addJs"><script>prototype/validation.js</script></action>

    <action method="addJs"><script>scriptaculous/builder.js</script></action>

    <action method="addJs"><script>scriptaculous/effects.js</script></action>

    <action method="addJs"><script>scriptaculous/dragdrop.js</script></action>

    [/code]

  3. Anywhere within that block definition, add the following line:

    [code]<action method="addJs"><script>lib/ccard.js</script></action>[/code]

To update the “core/profiler” block:

  1. Scroll down to the end of the block and look for the “core/profiler” block type.

    [code]<block type="core/profiler" output="toHtml"/>[/code]

  2. Add the “name” attribute as follows:

    [code]<block type="core/profiler" output="toHtml" name="core_profiler"/>[/code]

Save the changes to that file and clear the cache.

Changes to the Pager & Toolbar

The other theme update that occurred in the 1.4 release deals with the way the toolbar pager works. A Google search returns a number of different workarounds for this change, but I’ve found that the one offered in Magento’s release notes for 1.4.0.0 works the best.

  1. Back up your theme’s toolbar.phtml file by renaming it to .orig or .bak:

    [code]mv -v app/design/frontend/mypackage/mytheme/template/catalog/product/list/toolbar.phtml{,.bak}[/code]

  2. Copy the new toolbar.phtml file from the base package:

    [code]cp -pv app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml \

    app/design/frontend/mypackage/mytheme/template/catalog/product/list/[/code]

  3. Open the catalog.xml layout file in your favorite editor and append this line:

    [code]<block type="page/html_pager" name="product_list_toolbar_pager"/>[/code]

    Underneath this line:

    [code]<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">[/code]

  4. You should find two locations in that file where you’ll need to add the new “page/html_pager” block.

Changes to the Wishlist Layout

Finally, a modification of the wishlist.xml layout file should take care of a change that occurred in 1.4.2.0.

  1. Open the wishlist.xml file in your text editor.
  2. Find the following block:

    [code]<reference name="top.links">

    <block type="wishlist/links" name="wishlist_link">

    <action method="addWishlistLink"></action>

    </block>

    </reference>[/code]

  3. Replace it with the following:

    [code]<reference name="top.links">

    <block type="wishlist/links" name="wishlist_link"/>

    <action method="addLinkBlock"><blockName>wishlist_link</blockName></action>

    </reference>[/code]

Keep in mind that for each of the above modifications you will need to clear the cache to see the change. These theme updates are ones we find ourselves making every time we upgrade a shop from the 1.3 release or earlier. So, if you don’t want to scrap the hard work you put into your designs, give these updates a try. Chances are, you’ll still find some bugs, but hopefully you won’t have to start from scratch.

Nexcess
Nexcess

Nexcess, the premium hosting provider for WordPress, WooCommerce, and Magento, is optimized for your hosting needs. Nexcess provides a managed hosting infrastructure, curated tools, and a team of experts that make it easy to build, manage, and grow your business online. Serving SMBs and the designers, developers, and agencies who create for them, Nexcess has provided fully managed, high-performance cloud solutions for more than 22 years.


We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.