Implementing High-Res Images on Magento’s Native Responsive Theme

With retina displays becoming more and more common both on desktops and mobile devices, supplying appropriately high-resolution imagery is an important consideration. Blindly providing high-resolution images, however, wastes bandwidth – a resource in short supply, especially with mobile devices.

New specifications allow websites to provide an array of images at different resolutions to the browser so that it can pick the best fit for its display density and bandwidth availability. Adding support for this ensures that cutting-edge devices (and their lucrative owners) enjoy the best possible experience, while not penalizing traditional devices and users with traditional display densities with increased bandwidth usage.

Native RWD theme support

By default, the native rwd/default theme makes a very modest attempt to supply high-resolution images on the product detail page and no attempt on product list pages.

Product list pages load a conservative image that never exceeds its max render size. Since there can be many images loaded on a single category page, loading a higher than necessary resolution image for every product would have resulted in significant bandwidth increase while only improving the experience for high-density displays.

Due to the importance of product imagery on the product detail page, however, the product detail image gallery intentionally loads a 1.5x image. Product detail images are usually reasonably few, so this approach doesn’t require excessive additional bandwidth. The extra .5x leaves a little extra resolution for lower density displays and meets higher-density display halfway, all without cluttering or complicating the often-customized product media template and javascript.

Adding support for high-resolution images

In order to provide native support for forward-thinking browsers while maintaining high-performance backward compatibility for older browsers, the Picturefill polyfill is an easy choice. This polyfill uses the standard DOM structure to express image choices so that native browser support can be used where available, and fills in the gaps where necessary.

This polyfill supports both standard markup patterns:

  • img element with srcset and sizes
  • picture element with source nodes

While the picture element provides incredible flexibility, a standard img with appropriate 1x and 2x srcset values goes a long way with minimal impact.

Adding picturefil polyfill

After downloading picturefill.js, move to the /js dir to make available to all themes. Then, add a few lines to your theme’s appropriate layout XML update file to include it on all pages.

Product List

Product list images are very simple. By default, they are a simple img element, duplicated on both sides of the grid/list conditional.

Images will never exceed 400px rendered size, so a reasonable and bandwidth-friendly 300px max was chosen.

While this is acceptable for low-density displays, the stingy resolution shows up on high-density displays.

Due to the effective use of a simple img element, this is a textbook example of the implementation of 1x/2x images. Lower density displays are already accounted for, so the 1x image remains the old 300px standard. Adding a value to srcset for high-density displays is as easy as another call the Magento image resize helper, asking for an image 600px in size.

This simple change results in significantly sharper images on high-density displays.

This usage can be directly replicated on the other side of the list/grid conditional.

Product detail

Product detail images are only slightly harder. Due to the Magento’s gallery functionality, the product media template has an img element for the base image, followed by each gallery image.

By default, images are loaded at no higher resolution than 1200px – roughly 1.5x the actual max render size.

Again, due to the use of a simple DOM structure containing simple img elements, the switch to responsive images is not rocket science. After experimentation, images are never rendered more than 700px x 700px. This gives the target for the baseline, lower density, 1x target size, with 2x images targeted at 1400px – twice the baseline size.

Finally, a zoom size must be selected. Elevate zoom, the zoom library used by default only supports a single zoom image per img element. In order to provide a sufficiently bigger image for all display densities, a size adequately bigger than the high-density image size (1400px) must be chosen. This decision depends on the original resolution of product images available.

With the main product detail media image out of the way, updating gallery image thumbnails is a breeze. Simply switch to srcset, request a doubled image size from Magento’s image helper for the 2x image, and move the image size into a variable, just for good measure.

Product image considerations

No good deed goes unpunished, and neither does responsive image implementation. In order to actually provide high-resolution images to high-density displays, the original uploaded product images must be the highest resolution available. In particular, they must be at least ~2000px x ~2000px – enough to satisfy the resolution demands of the product detail zoom image.

Where to go from here

This article only scratches the surface – the more flexible picture element support allows for a wide range of sophisticated image use such as

  • providing images in different formats to take advantage of the latest standards
  • art direction for product images at various render resolutions

The code for this walkthrough is available on GitHub and can easily be installed via modman – use it wisely.

This post was the first in Classy Llama’s technical blog series on RWD on Magento.

We experienced the development of RWD theme first hand and want to share our learnings with you. In the next few weeks you can look forward to learning about the topics listed below:

Compile Compass in PhpStorm, Netbeans, or Sublime with source map support– The new Magento responsive theme uses Compass to compile Sass into CSS. In this article, learn how to automatically compile your Sass files whenever they are changed in your favorite IDE.

Sass Deployment Structure– In this article, we’ll cover how Classy Llama incorporates Sass compilation into our development and deployment workflow.

Interested in a responsive image implementation on your website? Let us know at our contact page.

Imagine Conference 2014 Was Epic…

It’s been a week since the conclusion of Magento’s Imagine Conference 2014 and the best way we can describe it is “epic.”

Here are some bite-sized highlights from the week:

-While there, Magento announced the release of Community Edition 1.9 and Enterprise Edition 1.14, which featured a fully responsive front-end built by Classy Llama and Brendan Falkowski.

-Classy Llama’s CEO, Kurt Theobald, was on stage for the first Keynote to demonstrate the new theme’s many great features and also share an example of a large-scale implementation of this powerful new theme.

-We launched The Llama Commerce Platform, which introduces a new a better way to build on Magento.

-Eric Wiese, who served as the technical lead on the Magento responsive build, received the opportunity to lead a breakout session regarding the fundamentals of building on the Magento responsive theme.

-We filmed four episodes of The Llama Commerce Show with incredible experts from companies like MailChimp and Yotpo.

-Almost 400 adorable plush llamas were given at our booth.

As you can see, there was a lot of great things going on this year at Imagine. We can’t say thank you enough to the folks at Magento and eBay who organized the conference and the many sponsors and merchants who really made it great. We’re already looking forward to next year!

Introduction to Responsive Design & eCommerce

The current buzzword/trend in the world of website design and development is “responsive.” It seems everyone wants a responsive site these days. If you’re a merchant, web programmer, or anyone else who deals with online media you’ve probably heard or read about responsive design and might want to know how it applies to you. As a merchant running an eCommerce site, I believe that a responsive design can add a lot of value for your visitors.

Since we deal exclusively with eCommerce here at Classy Llama, I’m going to spend a little time covering responsive design and then dig a little deeper into why it matters for eCommerce sites.

What Is Responsive Design?

The quick version is that a responsive design is a website design that changes and adapts to fit whatever device is being used to view the website. The design “responds” to the site visitor’s device and browser. A responsive design is also built to handle multiple input types so that it can be used on a touch device just as effectively as a device with a mouse.

All Your Stuff in One Place

In the multi-device world in which we live, many people will browse the web on a smartphone, a tablet, and a desktop computer. A good responsive design will display well and be easy to use on whatever device the visitor is using. Many new web technologies make it possible for the same site to work well on both a tiny smartphone and a giant desktop screen.

A responsive design uses the same design for both desktop and mobile devices. A responsive design maintains, as much as possible, consistency between the large desktop layout and the smaller mobile layout. Because it’s a single design for a site, a responsive design also contains all the same information for access on any kind of device.

Responsive vs. Mobile Websites

Although programmers have been creating “mobile” websites for a few years now, the key difference between a responsive design and a site with a traditional mobile design is that the mobile design is usually separate from the main site design. This generally means that the mobile site has different controls, a different layout, and must be loaded separately from the desktop design. Sometimes, with a mobile site, some website content isn’t available on the mobile site. Responsive design uses the same page content everywhere instead of splitting it up into separate sites.

Since I want to focus more on the eCommerce application of responsive design here, I’ve included links to a handful of articles at the end of this post where you can learn more about general responsive design.

“What about a mobile app?”

Since responsive design most often comes up when considering users with mobile devices, merchants have asked me about building a smartphone and/or tablet app instead of a responsive design. Apps are all the rage these days, with large app store companies posting big numbers about the number of apps users have downloaded and installed on their smartphones. However, there are a few reasons to prefer a responsive design to a mobile app.

1. Barrier to Entry

Using an app requires getting that app from the appropriate app store. A visitor who wants to use a site that only offers a mobile app has to go to the app store, download the app, and only then can they visit a mobile-friendly version of the site. This is a hassle and takes extra time, whereas with a responsive design the visitor can simply use the browser already installed on their phone to immediately begin browsing the site.

Additionally, many smartphone users have many apps installed already and are reluctant to add more. A user may not even have the storage space on their phone to add another app. If a website isn’t likely to be used often (e.g. if your website isn’t Amazon.com) then a user is going to be less inclined to install a dedicated app. With a responsive design, the user doesn’t have to install anything.

2. Multiple Platforms/Devices to Support

Because of the way that apps are programmed they are specific to a certain operating system and device type. For example, an Android app won’t work on an iOS device. Similarly, a smartphone app may not work very well on a tablet and vice versa. In order to support all the possible devices, a website will usually need multiple apps, which increases programming time and cost. Because a responsive design is designed to flex to fit different devices and runs in a regular web browser, it works on virtually all devices.

3. Separate Information Management

Because an app (or multiple apps) have to be programmed separately from a website, the information they contain generally also has to be managed separately. The website operators either have to duplicate their content creation and management efforts or create a sophisticated technical system to keep all the information up to date. Even then, information for the website may not fit very well into an app. With a responsive design, the information only has to be entered once on the website and it will automatically fit itself to all the devices with which visitors will browse the site.

Why should I care about responsive?

I hope I’ve made a clear summary case for why responsive is the right option for supporting your website on all kinds of different devices. But should you worry about these devices? Why should you care about all these smartphone-using people? Don’t serious customers use desktop computers anyway?

1. Mobile Web Traffic Trends

According to a report from Internet Retailer[1], mobile device web browsing made up nearly a third of all web traffic. That’s a pretty big chunk of users who are using all kinds of different devices to browse the internet and the number probably isn’t going down anytime soon. The percentage of web traffic grew 35% from 2013 to 2014 according to the Internet Retailer report[1].

What this tells us is that users are only going to be using their mobile devices more and more to browse websites. As an eCommerce website operator, all those visitors represent potential customers. It’s important to make sure that you’re not giving a third of your visitors a terrible experience on the device they want to use. Implementing a responsive design is like laying out a friendly welcome mat for them.

2. Untapped Opportunity

For many merchants, mobile traffic is a smaller percentage of their traffic and a very small percentage of their conversions. Based on this, I’ve found that some merchants have been hesitant to make the jump to responsive design. However, for many of these merchants, responsive design could unlock sales and visits that they don’t even know they could get.

If a visitor on a mobile device gets a bad website experience, of course, they aren’t going to browse around to shop and buy products. It’s very reasonable that they don’t visit much and don’t convert. However, if you implement a responsive design to give those visitors a great website experience, you might unlock a whole new category of mobile device sales. For an example, read the article linked at the end of this post to learn how a Magento responsive design helped create success for a merchant named Skinny Ties[2].

3. Many Device Form Factors

If you’re not already sold on a responsive design, keep one more thing in mind. It’s important to be welcoming to visitors no matter how they come to you and today those visitors have a huge range of devices available for browsing the web. Tablets and smartphones now come in dozens of sizes. There are even phones so big they’re called “phablets”, which fit in between the other device types!

With a responsive design, you’ll be ready for all of these visitors, no matter which device they’ve chosen to use. Even better, your site will be ready for visitors using devices nobody has seen yet because a responsive design adjusts itself to fit whatever device is being used.

Conclusion

I sincerely believe that for many eCommerce operators responsive design is the next big thing, a step that will unlock a whole new wave of sales. Up until very recently, it has been quite expensive to implement a responsive design, especially on the Magento platform. Even when considering everything I detailed above, the ROI hasn’t been strong enough for most merchants to make the switch.

However, that’s all about to change. Here at Classy Llama, the team and I have been able to work on some innovative, exciting new projects that we believe will make responsive design accessible to Magento merchants who didn’t even have the option before. I believe that not only are the benefits of responsive design clear there for merchants using responsive design on Magento, the value soon will be too.

Watch this space for updates on this exciting news! Or, if you’re just itching to get started and can’t wait, email[email protected] or call us at (417) 866-8887 to learn more.

Cheers!

References

More on Responsive Design

21 Powerful Tips for Better Conversions

If it weren’t copyrighted we might title this article “Chicken Soup for the Online Marketer’s Soul.” I know it’s a bit cheesy. But this is practical, nourishing stuff, from an online money-making perspective. The article is all about giving you some rapid-fire bits of wisdom that will increase the performance of your website right away.

1. Always use a powerful, benefit-oriented headline. Every page on your site including your home page, individual landing pages, and even blog posts need a headline. Contrary to popular belief the name of your company is not a headline. Your headline should communicate, in a very powerful and believable terms, a strong benefit that you can deliver that will be of interest to your prospects.

2. Don’t talk too much about yourself. Nobody like the “self-absorbed” person and no one will pay attention to a “self-absorbed” website. Each page should be about the client, his problems, desires, and needs and how your product or service meets those needs. You should only talk about your company in terms of how it relates to your customer.

3. Don’t get too technical. Watch out for too much jargon. It’s usually better to err on the side of simple explanations. Don’t assume too much. Confused prospects don’t buy.

4. Write your copy like you are talking to one prospect – not a big group. Some ad writers make the mistake of writing their web copy like they are addressing a large crowd. “some of you out there today may be thinking…..” No. It should be “You may be thinking that the economy is headed for the toilet. Let me show you how you can still prosper.” Write your web copy as though you were having a nice sit-down conversation with your ideal prospect.

5. Always give your prospect a “next step” offer. Every page should have an objective. The objective should be convincing your prospect to take the next step in the buying process. That next step may be making a purchase, it may be a face-to-face appointment, it may be signing up for a trial offer, or taking part in a special sale or event. Always be pulling visitors deeper into your sales process.

6. Sell the most compelling benefit. Most products and services have a host of benefits attached to them. You should zero in on the most powerful and most compelling one. Spend most of your time here. Mention some of the other benefits of the cherries on top, but spend the majority of your time and effort on the most desirable benefits.

7. Don’t focus on features. Features tell, benefits sell. A feature is what a product or service is or has. The benefit is what it will do for your prospect. If you stop at features you’ll be stopping short of tipping the scales in favor of the prospect making the purchase. Yes, always mention features (especially if you are selling a physical product), but take it one step further – drive home the benefit.

8. Think like your prospect. What keeps your prospect awake at night? What are their secret wants and desires? What do they want most when buying whatever it is you sell? What will it take to convince your prospect? You have to first think like your prospect before you can effectively persuade them.

9. Speak your customer’s language. Every group has its own language. Every industry, every religious group, every club or organization has its own language. When you learn to speak the “language” of your prospect, you become one of them and they will relate to you more, and buy from you more.

10. Use short words versus long words. USA Today’s website is written at a 6th grade reading level. Don’t make your landing page or home page read like a term paper – make the words short and easy to read. Don’t use two words when one will do the job and don’t use a long word when a short word will do the job.

11. Use short telegraphic sentences. Keep sentences short. Punchy. Your sentences should be telegraphic. They should each ring with clarity. Your reader should be able to fly through your landing page without getting hung up trying to decipher what you are trying to say. One or two “bumps” in the road on your site and your visitor will be gone.

12. Focus on what your customer wants – not what you want. Remember prospects spend 95% of their time (or more) thinking about themselves; their interests, their needs, and their wants. Join them in talking about what they are interested in and you will win them over quickly. Customers don’t care what you want unless it will help them get what they want.

13. Have a passion for your product and for your customer. Nothing sells like passion. That’s why the brand new sales guy loaded with enthusiasm can sometimes outsell the veteran even though the veteran has more knowledge and experience. Become passionate about your product and what it does for people (even if your product is a seemingly unsexy). If you aren’t excited about your product, your customer won’t be either.

14. Show, don’t tell. Remember don’t just tell your prospect about your product or service. Paint a picture in their mind of how their life will be better after using the product. Give examples, use analogies, make your pages vivid and alive. Allow you prospect to get a 3D picture of what they will experience after doing business with you. Videos, images, and case studies do a great job of “showing” your products benefits.

15. Prove every claim that you make. If you say you are the best – back it up. If you say you offer superior service give an example. If you make a claim and then fail to offer some proof to affirm it, then people will discount what you are saying. What do I mean by proof? Well I’m not talking about a stack of evidence like they use in courtrooms, but you do need enough evidence for a customer to say, “OK, these guys probably really are good.” What could you use for proof? Awards, expert endorsements, charts and graphs, facts and figures, testimonials, analogies, product demonstrations and more.

16. Use Testimonials (or Product Reviews). Regardless of the industry you are in or the product you sell, you will undoubtedly benefit from the correct usage of testimonials. Your testimonials should serve to re-enforce and validate the claims you make in your sales copy. Here’s a caveat though; bland testimonials are worthless. You want your testimonials to actually say something of substance. The old, “XYZ staff is polite,” just doesn’t carry much weight. You want something like, “I always go to XYZ. I’ve tried dozens of other options and they are hands-down the best I’ve ever tried, anywhere and at any price.” Make the best use of testimonials in your sales copy and in your videos on your site. Good testimonials are marketing gold.

17. Know your customer. Knowing your competition is important but knowing your customer is infinitely more important. You must have an intimate knowledge of your customers (especially in relationship to whatever it is you sell). You can get a serious leg-up on the competition just be relating to and communicating better to your customers and prospects.

18. Make your aim selling, not impressing. Your goal for every page on your site should be to move a prospect to buy or to take the next step in the buying process. I remember suggesting a very strong marketing idea to a client of mine a few years ago and he responded, “I don’t know what my colleagues will think.” The answer should be “who cares!” As long as what you are doing is legal, ethical, and moral, then what the prospect thinks is all that matter. Leave the impressing of your golf buddies, or colleagues to someone else. You focus on impressing your banker with all the cash you are making.

19. Show some personality. Use personality in your ads. It’s been proven that people relate better to other people than they do with organizations and institutions. That’s why the Lee Iacocca Chrysler ads long ago were so effective, and that’s why the Gary Vaynerchuk and his Wine Library TV make such an impact. People don’t want to do business with a lifeless corporation – they want to do business with other people.

20. Drive home your USP (Unique Selling Proposition). After someone is exposed to your ads and marketing pieces even just a handful of times, they should be able to summarize what makes you unique (your USP). If you often hear people who have been exposed to your marketing ask the question, “what do you do again?” you know you’re USP isn’t being presented clearly enough.

21. Be specific. Specifics are believable and powerful. Generalities are weak and are usually dismissed without much thought. If I tell you I can save you money – you may or may not believe me or get excited. If I tell you that I can help the average customer save over $500 every year – then I might get your attention. Certainly there are other things to keep in mind as you add conversion power to your website. But, if you keep these things in mind you should see a healthy increase in response and conversion from your site.

PayPal Tokenization Extension Now Features Broader Support

In late 2013, Classy Llama released our PayPal Credit Card Tokenization extension. The primary feature of this extension is to introduce a “saved credit card” option for merchants without the necessity of compliance with PCI DSS standards, by leveraging card data stored securely on PayPal instead of on a merchant’s site. Read more of the details in the original post.

When we first introduced it, the extension’s compatibility was limited; it supported only the latest version of Magento at the time. We promised that support for earlier versions of the platform would come eventually, and we’re happy to announce that the extension’s latest release implements compatibility back through Magento Community 1.5 and Enterprise 1.10 (as well as officially certifying compatibility with the latest versions of 1.8 and 1.13). Now a much broader segment of merchants has a great option for allowing their customers to save and reuse their credit card details!

Get the extension here: http://www.magentocommerce.com/magento-connect/paypal-credit-card-tokenization-extension.html. As ever, the best thing about the extension is that it’s free!

Multi-Environment Magento Development with Modman

Note: modman, the tool that is the subject of this article, is for *nix or Mac OS X only.

As an agency, most of our development at Classy Llama has typically been done in a self-contained context; one site, one codebase, one VCS repository. Even when a particular piece of functionality was reused, it tended to be directly copied from point A to point B and be re-tooled along the way.

If you’re a Magento developer, chances are better than average that your version control workflow is similarly straightforward. (Because chances are better than average that either you work in an agency context, or you manage one or more Magento sites for a single business.) What product developers – like those heroes who create hosts of Magento extensions that make our lives easier – know is that workflow quickly becomes more complicated when you’re developing functionality that must work across multiple sites and even multiple versions of the platform. When creating a distributable extension, your end deliverable is that extension’s code and nothing else. But you still have to develop it within a working Magento codebase – multiple in fact, presuming you want it to be compatible with multiple Magento versions.

You might find yourself with a similar need for your version control workflow, even if product development is not your area. As agencies mature, we tend to value more and more the efficiency gain from packaged functionality that’s easily reusable. And if you’re an in-house developer, imagine a scenario where you manage two different brand sites but need to simultaneously build the same feature for both, or perhaps version 2.0 of your site is in the works but a fancy new piece of functionality needs to go up ASAP. Many scenarios can lead to the need for rapidly deploying and testing one extension in different contexts.

We developers can come up with some embarrassingly half-baked solutions to challenges like this because we want to keep our focus on what we’re creating, not pesky issues like manageable workflow. The good news is that such workflows can be dead simple when you equip yourself with the right tool. And in this case, the right tool is modman, a lightweight program created by Colin Mollenhour.

Note: The focus of this article is on version control workflow across multiple codebases. It is not comprised of tips on making your code more universal/distributable.

Note the Second: This article also presumes that you are using version control in your development. If you aren’t . . . we were all there once! Don’t beat yourself up; just start using a VCS. Here at Classy Llama, we use git.

Using modman

Let’s get down to it and define our scenario. We’re developing a useful extension that we’ll call, unimaginatively, MyShop_UsefulExtension. And for whatever reason, it does not belong to one particular site, but must be tested on several. Our VCS repository will contain only the extension code:

app/
    code/
        community/
            MyShop/
                UsefulExtension/
                    etc/
                        config.xml
                    Model/
                        Observer.php
    design/
        frontend/
            base/
                default/
                    layout/
                        usefulextension.xml
                    template/
                        usefulextension/
    etc/
        modules/
            MyShop_UsefulExtension.xml
skin/
    frontend/
        base/
            default/
                usefulextension/

. . . and our challenge is how to keep full working Magento codebases synced with this code while we develop. Our VCS itself makes it easy to have multiple running working copies of the code, of course, but what makes Magento and platforms like it a special challenge is that all of these files need to be distributed throughout the main codebase instead of being contained in one place. How do we make sure our own code is simultaneously isolated for version control and also plugged into all the right places so we can actually run it?

We could perhaps solve this problem by creating a meticulous list of paths for our VCS to ignore, in which case our repository root could coincide with the root of the Magento site codebase itself. But this could end up a bit daunting to maintain, and there would always be the possibility of accidentally committing a file that isn’t actually part of our code. (Not to mention that if the codebase where you want your extension deployed is itself under version control, this option goes immediately out the window.) modman has a better way.

modman takes information about the repository that contains your module (git and Subversion are supported) and takes care of both updating your local copy and merging its files into the main codebase.

The program was written specifically with Magento in mind, but it can be used for any platform with similar requirements. Visit the GitHub page for easy installation instructions:

https://github.com/colinmollenhour/modman

Once we’ve taken care of installing modman, we need to prepare our extension to utilize it. This is as simple as adding a file called “modman” to our root, containing mappings between the files/directories in our repository and their respective locations in Magento:

app/code/community/MyShop/UsefulExtension app/code/community/MyShop/UsefulExtension
app/design/frontend/base/default/layout/usefulextension.xml app/design/frontend/base/default/layout/usefulextension.xml
app/design/frontend/base/default/template/usefulextension app/design/frontend/base/default/template/usefulextension
app/etc/modules/MyShop_UsefulExetension.xml app/etc/modules/MyShop_UsefulExetension.xml
skin/frontend/base/default/usefulextension skin/frontend/base/default/usefulextension

The left path on each line is the path to the file or directory relative to our repository root. The right path indicates where this file or directory should be copied to in the main codebase. With an extension structured as straightforward as ours, these are conveniently the same.

With the modman file in placed and pushed to the repo, all that’s needed in our Magento codebase is to initialize modman and kick off the clone/copy of our extension:

cd /path/to/web/root
modman init
modman clone MyShop_UsefulExtension [email protected]:MyShop/usefulextension.git

The above commands result in the extension being cloned into “MyShop_UsefulExtension” in a special directory called “.modman”. By default, the files as specified in the manifest file are actually symlinked into the main codebase rather than being copied directly.(Make sure you follow the installation instructions and enable symlinks for templates in the Magento admin.) This has two major advantages: First, already deployed files will stay in sync as you develop without the need for redeployment. And second, broken symlinks can easily be identified and removed in the event you delete files from your extension.

Here’s the view from our web root directory:

.modman/
    MyShop_UsefulExtension/
        app/
        skin/
app/
    code/
        community/
            MyShop
                UsefulExtension -> ../../../../.modman/MyShop_UsefulExtension/app/code/community/MyShop/UsefulExtension
    ...

The “init” and “clone” commands should be run in every codebase where you need to develop and/or test your extension. As you work and push new changes, keep each codebase updated with the following:

modman update MyShop_UsefulExtension

The above will pull your latest changes from the repository and re-deploy files as specified in the “modman” manifest.

It’s really that simple. With these basic commands, you can smoothly proceed with the development of a self-contained extension in as many contexts as you need.

modman has a few more useful tricks you’ll find it helpful to know. Additional commands can be passed directly to git or Subversion by including them after the modman command, such as the following, which clones a specific branch initially:

modman clone MyShop_UsefulExtension [email protected]:MyShop/usefulextension.git --branch develop

You can also tell modman to perform the deployment of symlinks into the main codebase without bothering to update the extension working copy first by using the “deploy” command. (A common need when you’ve just added new paths to the “modman” file.)

modman deploy MyShop_UsefulExtension

I mentioned above that one benefit of using symlinks was easy clean-up of deleted module components. modman has a command specifically for this purpose: “clean”, which will find leftover symlinks from previous deployments and remove them.

modman clean

In certain circumstances, you may find it desirable for your extension files to be directly copied into the Magento codebase instead of symlinked. (For example, as a handy way of installing your final extension on a given site.) The “–copy” flag can be used with any command that typically performs the file deployment:

modman clone --copy MyShop_UsefulExtension [email protected]:MyShop/usefulextension.git

Just take note that the “clean” command will become useless when files/directories have been deployed via copy, as there will now be no broken symlinks to be identified if you should delete a path from your manifest file later.

A final tip on using modman for your Magento development: It’s important to use the appropriate degree of specificity for paths in the “modman” manifest file. It’s fairly obvious that we wouldn’t want to simply include the path “app/code” in our manifest file. This would result in that entire directory being wiped out in our main codebase, in favor of the contents of our extension! However, using the example structure we’ve established above, it would seem reasonable to include the generalized path “app/code/community/MyShop”. But imagine a scenario where you’ve created two modman-compatible extensions under the same vendor namespace and want to deploy them both to the same codebase. The “MyShop” directory can’t be symlinked from both. That’s why you’ll notice in my example manifest file that I’ve used the more specific “app/code/community/MyShop/UsefulExtension”. Always use paths appropriately specific to the extension; paths that no other module should touch. modman will create the correct intermediate directories where needed.

When you need to develop an extension in a packaged, distributable manner, you’re likely to have headaches enough ahead of you from the development alone. Finding an efficient way to deploy your work across these workspaces and keep it in sync doesn’t need to be one of those headaches. Colin Mollenhour has provided us a fantastic tool to meet that challenge.

Learn more about the program at the modman wiki.

Widgets in Magento Commerce

Widgets in Magento Commerce allow business users to insert different kinds of content throughout the front end of their websites without having to write a single line of code. Widgets are a commonly underused feature in Magento, as they aren’t the most intuitive feature and until you create one or two, it is not always clear how to accomplish what you want.

In this article, we’re going to cover:

  • Overview of Widgets
  • Types of Widgets
  • Where you can insert Widgets
  • A couple of real-world examples of Widgets in use

Overview of Widgets

Prior to the introduction of Widgets in Magento Commerce, if you wanted to insert content into any of Magento’s layout blocks (header, left column, main column, footer, etc) you needed to use Layout XML. For developers, this was fairly straightforward. But business users found this clunky and difficult to work with.

Widgets are Magento’s answer to the problem of how to conditionally insert content into any section and page of your site. Combined with Banners/CMS Blocks and Customer Segments, you can get really creative in displaying targeted marketing to your customers.

Types of Widgets

This is a list of all of the Widget types in Magento:

Banner Rotator
Insert one or more banners
CMS Hierarchy Node Link
Insert a link to a specific CMS page OR to a CMS node. This is helpful if you want to insert a CMS menu into all CMS pages.
CMS Page Link
Link to a specific CMS page
CMS Static Block
Insert a Static Content block.
Catalog Category Link
Link to a specific Category
Catalog Events Carousel
Display a list of all Catalog Events on site.
Catalog New Products List
Insert a list of new products
Catalog Product Link
Link to a specific Product
Gift Registry Search
Insert a form to allow user to search for registry
Order by SKU
Insert an “Order by SKU” form
Orders and Returns
Insert a form that allows guests to find their order using their Order ID, Last Name, Email, and Zip.
Recently Compared Products
Insert a list of recently compared products
Recently Viewed Products
Insert a list of recently viewed products
Wishlist Search
Insert a form that allows a visitor to search for a wishlist

Where you can insert Widgets

When you create a new Widget Instance, you have to decide on what pages you want that Widget to display and in what blocks on the page that widget should display in. You’ll do this in the “Layout Updates” section.

  • You will first choose a “Display On” value to tell Magento what page you want this Widget to display on. If you want to use the Widget on multiple pages, you can insert multiple Layout Updates using the “Add Layout Update” button.
  • You will now need to choose where on the page you want this Widget to show—you’ll do this using the “Block Reference” drop-down. Depending on what Widget type and “Display On” you have selected, different options will show here, but this is a list of the commonly available locations:
    • Breadcrumbs
    • Left Column
    • Main Content Area
    • My Cart Extra Actions
    • Navigation Bar
    • Page Bottom
    • Page Footer
    • Page Header
    • Page Top
    • Right Column
    • Store Language

This is a screenshot explaining what each of those locations relates to:

Example 1

A massive snowstorm just buried your main warehouse. You need to let all of your customers know that their shipments are going to be delayed by a couple of days, so you want to display a site-wide message with this information.

  1. Create a CMS Static Block that contains the content you want to display.
  2. Go to “CMS > Widgets” and click “Add New Widget Instance”
    • Select “Type: CMS Static Block” and the appropriate “Design/Package Theme” value
  3. Select these options on the “Frontend Properties” tab:
  4. Select these options on the “Widget Options” tab:

Your message will now be displayed on all pages:

Example 2

Your store offers free shipping if an order is equal to or greater than $100. You want to promote this offer to customers that have less than $100 in their cart by telling them about the promotion and you want to congratulate customers that already have $100 in their cart by telling them that they’re getting free shipping. To accomplish this, we’re going to use a combination of Customer Segments (what visitors to display the message to), Banners (what message display), and Widgets (where to display the message).

  1. Create a Customer Segment called “Less than $100 in cart” and add this condition:
  2. Create a Customer Segment called “More than $100 in cart” and add this condition:
  3. Create a CMS Banner called “Free Shipping – Order $100 to Qualify”. In the “Content” tab, insert a message like “<h2>Free shipping over $100!</h2>” Alt "Banner Less than $100"
  4. Create another CMS Banner called “Free Shipping – Your Order Qualifies”. In the “Content” tab, insert a message like “<h2>You get free shipping since you’re ordering over $100!</h2>”
  5. Now that you’ve created the Customer Segment and Banners, we’ll tie this all together with a new Widget:
    • Create a new Widget Instance with the type of “Banner Rotator”
    • Select these options on the “Frontend Properties” tab:
    • Select these options on the “Widget Options” tab:

Once you finish these steps, you can see it in action:

Conclusion

After reading this summary of Widgets, I’d recommend referring to the “Widgets” section of the Magento Commerce User Guide to get answer any questions you might have. Hopefully, this overview will help you see how you can use Widgets to more effectively run your business.

Currency in Magento

Magento is built to be an extensible multi-lingual, multicurrency, and multi-national platform. Its flexibility can create significant challenges for merchants and developers alike. This has led me to dig deep into the currency systems that are built into the pricing and sales portions of Magento.

At a basic level, native Magento currency options can be expressed as three possibilities. The first option is to simply have your base price set on every product using a single currency. This base price is the one that you set when you are setting the price value on a product at the default level.

The second option is to use Magento’s native currency conversion that operates at runtime on a per store basis. As a Magento merchant or developer, you have the option of allowing your customers to view prices in a different currency from the one in which they will be charged. This conversion is merely for evaluation purposes since the customer will still be charged in the base currency but they will at least get an idea of the approximate amount they will be charged after conversion. These conversion rates can be pulled from a conversion rate service or entered manually in the admin. If the rates are pulled from the external service, they can be set to automatically update daily. This type of conversion is often sufficient for merchants who do the majority of their business within one country and merely have the option of other currencies for those few countries that make up a minority of their sales.

For those who are targeting a larger percentage of sales in more than one country, Magento has a third option. A merchant can set a different currency at the website level from the one set at the default level. This allows the merchant to do everything from setting prices that are specifically formed to look good in that currency to charging the customer’s credit card in their native currency. This third option is the most time consuming and labor intensive of all of the currency options, but it also has the greatest potential benefit.

Using the Same Base Currency and Display Currency

Anyone who has worked extensively with prices in Magento knows that there are quite a few ways to modify those prices. Within native Magento Community Edition, you are required to set a price on a product at the default level. You also have the option to set a website specific price. Each of the following elements also has options to set pricing at default or web site levels, in addition to adding other more specific limitations upon who receives the price as implied by their names:

  • special pricing
  • customer group pricing
  • tiered pricing
  • catalog price rules
  • shopping cart price rules

All of these will be combined, along with any other pricing modifications that might come into play, to form the product’s final price. This final price is the total price of the product itself and excludes things like shipping, tax, and certain discounts which are applied to the entire order.

Both the base price and the display (converted) price are stored on the cart and both are transferred to the order at checkout. When the only allowed display currency is also the base currency, the base price is always the same as the display price. Both of these prices are then used throughout the life of the order. The display price is primarily used for display to the customer, and in certain places in the admin, while the base price is used primarily for calculations.

Differences when using Currency Conversion

When Magento is set to use a conversion rate other than 1 (which produces no conversion) it converts the base price to the display price before performing any other calculations. All other calculations are then simultaneously performed, using identical operations, on both the base price and the converted display price to arrive at the final totals for each price.

It is important to understand that, depending on the situation, the final display price total may differ by a cent or more from the value that would be generated by taking the final base price total and converting it. How much the values differ depends on the number of line items included in the calculation – though it should never be more than a few cents.

When a customer places an order, they will be charged the calculated base price total converted, by the payment processor, into the customer’s currency. Since this is not the way that the display price total is calculated, the display price total will only give the customer a close approximation of what the charge will be in their currency. It will not be an exact representation of actual charges.

Impact of using Multiple Base Currencies

Using multiple base currencies may seem confusing at first and it does require that the person who imports products is thorough. Because of this, I recommend that you have a strategy in place for implementing products with multiple base currencies before publishing them to a live production environment.

To understand the importance of being thorough in a situation where you have multiple base currencies, consider a scenario where a US run company has a large customer base in Europe and the UK. The merchant has already imported their entire product set that is offered across all of their stores. This merchant opens their European and UK websites with Euros and GBP as the websites’ respective base currencies. The merchant also has general shopping cart price rules set up for all websites giving customers 10% off Product A when purchased with Product B and 5 off Product C when it is in a cart where the cart totals 100 or more.

Some interesting things happen when you create websites with different base currencies to include these products. When a customer browses to the new website, he/she will find that the price has the same numerical value on the two new websites as on the US website. The product that is $100 on the US website will be €100 and £100 respectively on the European and UK websites. This is obviously not accurate and will happen whether or not you have currency conversion rates set up.

If each website has a different base currency, each website should have a different base price to go along with that currency. This different base price could be set by either having a separate product that is exclusive to each website or by having a product in multiple websites with a different website level price for each website.

By extension, the shopping cart price rules which were originally made for a scenario involving only dollars should either be split into multiple shopping cart price rules, converted into percentage based rules, or accepted as different value rules on each website. Some of these rules may still be logically similar, for instance, the rule that gives $5 off Product C when it is in a cart where the order totals $100 would be valid although slightly more expensive rule when it was offering €5 off a €100 cart.

The most important thing to realize with using different base currencies is that you cannot simply assume that all of your configured prices and rules will work as expected, but instead, each area of the admin where a price is entered must be evaluated for consistency with the new multiple base price structure.

Alternatives

While Magento has a few ways to deal with currency conversion, it is important to consider the implications of each of the factors for your customers when they are paying in a currency that is not your Magento Installation’s default base currency. There are other possible pieces to this puzzle that can come into play if native Magento alone does not suit your needs.

One possible option is to use PayPal Express as the only or primary payment method on websites that default to a display price other than the base price they will be charged. PayPal will show the user what they will be charged in their currency according to its conversion rates. This can protect your users from potentially having to pay credit card surcharges when they pay in a non-local currency.

Another option is to use a third party or custom solution that uses multiple base currencies. Classy Llama has built a currency conversion automator which allows the merchant to have the increased functionality and usability that comes with using multiple base currencies with a lot of the convenience of using multiple display currencies. This extension allows the merchant to enter a default price for a product and 1 or more website level prices. It then uses a set of rules and order of priority to convert one of the manually set currencies to each of the other website’s prices using the conversion rates set in the admin. The extension then round the price to make prices look consistent across the entire site.

For example, a product with only a default price of $10.00 where the system used USD as its default base currency, would have its base price on the UK website that used GBP as its base currency calculated by taking $10.00 times the conversion rate from USD to GBP and rounded to the nearest pound. So assuming that the conversion rate was $1.85 to £1 the product would have a UK website level price of £19.00 which is the converted price of £18.50 rounded to the nearest pound.

This type of solution obviously has certain limitations. For instance, shopping cart price rules are unaffected by this extension and tiered prices and customer group specific pricing likely would have used their own native currency selection options, but it is an example of how a combination of the manual and yet more precise and flexible nature of using multiple base currencies could be combined with the simple and automated nature of display price currency conversion.

Conclusion

As merchants and developers consider how to handle multiple currencies, it is important to consider the implications of each currency option. The merchant may choose to ignore currency conversion altogether, use currency conversion with display prices, or introduce multiple base currencies and accept the extra overhead incurred. The effort involved in using multiple base currencies is likely only necessary or beneficial to merchants who do not do the majority of their business in a single currency or who have separate distinct web presences for countries whose native currency is different from that of the merchant.

The use of multiple currencies on a website should not be considered lightly but should be approached from a strategic perspective that will allow for long term maintenance of the solution while still providing sufficient functionality to the merchant and customer alike.

Cutting Edge Ecommerce Payments — Accepting Bitcoin on Your Magento Store

Bitcoin, the world’s first digital currency, has been making waves in the economic and e-commerce circles since it was first introduced in 2009. Due to its recent media exposure, you’ve probably heard about Bitcoin and are wondering if this currency offers any competitive advantage to give you and your store an edge.

Bitcoin is fundamentally a currency, such as the US dollar, euro, or yen. Often incorrectly compared to the credit card networks, Bitcoin is actually cash — and should be compared to the banknotes in your wallet. What sets Bitcoin apart, however, is the fact that it’s a decentralized digital currency. Using cryptographic principles and a lot of heavy math, Bitcoin payments are sent and received over the internet, enforced and regulated using public/private key cryptography — the same industry standard encryption and verification mechanism used to secure SSL and SSH.

Due to its unique nature, Bitcoin has had a fair degree of success. As an economy, its market cap has exceeded $1 billion, with individual Bitcoins approaching the value of gold. The banking community has also recognized the advantages of the Bitcoin economy. Bank of America analyst Merrill Lynch states, “We believe Bitcoin can become a major means of payment for e-commerce and may emerge as a serious competitor to traditional money transfer providers”.

Why accept Bitcoin currency as payment?

Bitcoin offers a number of advantages to an e-commerce store. In short, Bitcoin allows e-commerce stores to accept a form of cash as payment with all its advantages and simplicity while retaining the convenience of remote credit card payments which customers have come to expect.

Cash equivalent payments

Due to the fact that it is a cash equivalent, Bitcoins are not susceptible to chargebacks — all payments are final, just as if customers had paid you in physical banknotes.

The major credit card vendors, such as MasterCard, Visa, and American Express, have created a largely cohesive payment network, allowing e-commerce stores to accept payments from a wide audience of card-holding customers. The reliance on these central networks, however, introduces overhead for stores which support them, requiring store owners to pay fees on transactions and comply with sometimes seemingly arbitrary requirements. Due to its decentralized nature, Bitcoin requires no intrinsic fees or specific business practice requirements — you can run your business in the way you see as most efficient.

Convenience

The most obvious convenience provide by Bitcoin payments is its digital nature — all the benefits of cash payments, but funds are instantly transmitted over the internet, ensuring that customers continue to receive the instant gratification of card-not-present transactions they’ve become accustomed to.

Going above and beyond the convenience of credit card purchases, Bitcoin reduces barriers to purchase. Specifically, due to its decentralized nature, Bitcoin purchases can be accepted internationally without any regulatory or infrastructure overhead. This means you can instantly accept payment from any country, regardless of the customer’s local currency or political climate — all without incurring any additional fees or overhead.

Security

As a cryptographic currency, Bitcoin provides unrivaled security compared to either cash or credit card payments. As advantageous and simple as physical cash payments are, they are intrinsically at risk of theft, requiring additional overhead to secure and transport. Using the same public/private key cryptography concepts as credit card payments, Bitcoin eliminates transmission theft risk.

Bitcoin also significantly reduces the effort required to secure customer payment information. With a traditional credit card purchase, the same credit card number transmitted by the customer to pay for a legitimate transaction can be used maliciously for illegitimate transactions. This requires businesses to go to great lengths to secure this information. Bitcoin, however, uses public/private keys to authorize payments. This means that the public address your store receives during payment is not sensitive. Even in the event of complete store compromise, no Bitcoin paying customer is at risk of theft due to the unauthorized release of their public address.

Cost

Finally, Bitcoin offers reduced transaction fees, compared to current credit card networks. Traditional credit card networks have many required players (credit card network, gateway, etc), each contributing to transaction fees. As illustrated below, accepting Bitcoin payments typically requires only one service, resulting in significantly reduced transaction fees.

How to accept Bitcoins

As a decentralized cash-equivalent, there’s nothing stopping an e-commerce store owner from implementing their own Bitcoin payment interface, with no fees whatsoever. However, there are several services which already exist with drop-in Magento modules, allowing you to accept Bitcoin payments in minutes. These provide the user flow to actually accept Bitcoin payments, integration with Magento, automated exchange to your local currency, and automatic withdrawal to a checking account if desired. Of the many options, BitPay and Coinbase are two of the biggest and most widely used.

BitPay

BitPay is one of the most widely used Bitcoin payment services, currently used by more than 12,000 businesses. While BitPay offers a free starter tier with 1% transaction fees, its flat rate plans really illustrate the savings potential of Bitcoin — ranging from $30 to $3000 per month. The cost varies by your accounting needs, not by transaction volume. BitPay’s Magento module provides direct checkout integration, allowing customers to seamlessly pay with Bitcoins. Payments can be withdrawn to an external Bitcoin wallet or automatically exchanged for your local currency and deposited in your checking account.

After creating an account with BitPay, install the free Magento module and flush the cache. From your BitPay dashboard, select My Account -> API Access Keys. Click Add New API Key, enter a meaningful memo and click Save Changes.

Now that you have the necessary API key, it’s time to configure Magento. In your Magento admin, open the BitPay configuration by visiting System -> Configuration -> Sales -> Payment Methods and expanding the Bitcoins section.

In order to activate the payment method, set Enabled to Yes, and enter the API key you generated above. Click Save Config to commit the changes.

Now that the BitPay module is configured with an API key and enabled, customers may pay with Bitcoins by simply selecting the new Bitcoins payment method.

After proceeding to the Order Review step of checkout, customers will be presented with the amount due in Bitcoins. A receiving Bitcoin address will be generated dynamically by BitPay, which is displayed along with a QR code for the customer’s convenience.

After paying the amount due using the Bitcoin software of their choice, the customer will see confirmation that their payment was accepted.

Now that the order is paid for, a final Place Order button click will take the customer to the order confirmation page.

Your store is now accepting Bitcoin payments! In the BitPay settlement settings, you can configure the currency you’d like to have your Bitcoin payment exchanged for, and configure a checking account for automatic withdrawal.

Coinbase

Similar to PayPal, Coinbase provides many Bitcoin related services to both customers and merchants, enabling easy integration with the Bitcoin economy. By allowing users to create accounts with preset funding methods, Coinbase can simplify the already short Bitcoin payment flow for users who opt to use an account. In addition, Coinbase supports Bitcoin recurring payments for account-holding customers. Coinbase charges no transaction or monthly fee for funds which are not exchanged to the merchant’s local currency; funds which are exchanged incur a 1% transaction fee after the first $1 million.

After registering for a Coinbase account, install the free Magento module and flush the cache. In your Magento admin, visit System -> Configuration -> Sales -> Payment Methods, and expand the Coinbase section. You’ll need to create an application on your Coinbase account, and the system configuration section has a handy link to launch this. Be sure and note the redirect URL — you’ll need this in the next step.

Once logged into your Coinbase account, enter the name of your store and the redirect URL from the system config page, then click Create Application.

Coinbase will associate your new application with your account and generate a client ID and client secret to authenticate the Magento module.

Enter the client ID and secret into the Coinbase section in your Magento system configuration, ensure the Enabled field is set to Yes, and click Save Config to commit the changes.

Once the client ID and secret are saved, you will need to authorize your new Magento application to accept payments. The system configuration changes to reflect this, and again provides a handy link.

Click the link to open the Coinbase authorization interface, and click Authorize.

After clicking Authorize, Coinbase will redirect back to your Magento system config, where you will see confirmation that the account is connected correctly.

As with BitPay, the Bitcoin payment method will be made available for customers. When a customer chooses the Bitcoin payment method and completes the order, they will be redirected to a PayPal Express-style payment screen hosted by Coinbase. Here they will have an opportunity to either log into their Coinbase account and pay or pay using an external Bitcoin wallet.

After sending Bitcoin funds, customers will see a confirmation that the payment was received successfully.

Clicking the Return to … Store button will send the customer back to your Magento store to see the standard order confirmation page.

Your store can now accept Bitcoin payments! In the Coinbase merchant settings page, you can configure Coinbase to exchange Bitcoins into your local currency and automatically deposit into your checking account.

Bitcoin payments offer many unique and unprecedented features which solve or eliminate many of the frustrations experienced by merchants when using traditional payment methods. These solutions improve efficiency, reduce overhead and expenses, and reduce reliance on centralized payment networks. Considering the efficient Magento store integration provided by Bitcoin payment services and associated modules, adding support for this payment method has never been easier.

Want to accept Bitcoin on your site or have a new site you’re looking to launch sometime soon? Drop us a line via our contact page.

Switching to Desktop When Using Design Exceptions for a Custom Mobile Theme

Amongst the leaders of eCommerce, it is widely known that mobile devices are increasingly comprising a very large segment of web traffic, one which cannot be ignored. The eCommerce Quarterly by Monetate reports that tablets and smartphones accounted for > 21% of all eCommerce traffic in the US during the first half of 2013, compared to only 2% two years ago. These users need an experience designed for them. Something which allows them to get what they want when they want it, and without having to deal with the hassles (and emotional trauma) of wading through a cluttered desktop-centric design on a screen the size of one’s palm. Enter mobile friendly web design!

There are two widely accepted means of appealing to mobile device users: responsive design and targeted design (i.e. the practice of having an independent desktop and mobile site). There are many advantages to using responsive design. It also has its cons…targeted designs do as well, like generally being more difficult to maintain feature parity.

Ok, so you need a mobile site, and quick. You don’t want to rebrand, rebuild, or risk upsetting your existing desktop-centric design. Or maybe it’s something you need to plan for in next year’s budgets — and you decide to go for building a mobile site which will serve your mobile customers better without changing anything on the existing desktop-focused design you have already.

Implementing a mobile site on Magento doesn’t have to be hard, and Magento includes one out-of-the-box, which is also available on Connect.

Turning this on for mobile devices is pretty simple. Just don’t forget that you do still need to change the stock orange to something fitting for your brand…unless you just love orange, then you can keep it! You can set this up in the Magento admin by navigating to System -> Configuration -> Design and setting a “Design Exception” — I.e. you tell Magento what theme you want to apply for browsers with a User Agent string matching a given RegEx pattern. One commonly used pattern is this one:

iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini

Another common use would be to use the above, but with “Mobile” excluded from the list of matching User Agent strings so iPads will (as Apple suggests) still serve up the desktop theme.

Given this approach, and seeing how it’s so easy to have disparate features between the Mobile and Desktop versions of your site, it’s not uncommon to hear something like, “It’s simple and beautiful, but I can’t switch to the desktop view when I want to.”

The ability to switch to the desktop theme from a mobile device is unfortunately not supported by the native iPhone theme out-of-the-box. However, this is definitely possible and not really that hard to accomplish!

Since the site is actually running on the same URL and serving up a different theme based on the User Agent, the technique here is to utilize a cookie to override the design exception and prevent it from being applied. Having implemented a number of mobile sites, we put together a small module to allow adding this sort of behavior to the mobile theme, complete with support for the Enterprise Edition’s FPC.

The critical piece of functionality is as simple as this: rewrite the core/design_package model and override a method to check for a cookie before allowing the design exception to be applied:

  class CLS_DesignSwitcher_Model_Core_Design_Package extends Mage_Core_Model_Design_Package
  {
      /**
       * Get regex rules from config and check user-agent against them. We override to
       * determine if the design exception should be ignored based on presence of a cookie.
       * 
       * @param string $regexpsConfigPath
       * @return mixed
       * @see Mage_Core_Model_Design_Package
       */
      protected function _checkUserAgentAgainstRegexps($regexpsConfigPath)
      {
          $ignoreException = null;
          if (isset($_COOKIE[CLS_DesignSwitcher_Helper_Data::FULL_SITE_COOKIE])) {
              $ignoreException = $_COOKIE[CLS_DesignSwitcher_Helper_Data::FULL_SITE_COOKIE];
          }
          return $ignoreException ? false : parent::_checkUserAgentAgainstRegexps($regexpsConfigPath);
      }
  }

I’ll not post the entire source here on the blog, but you can grab a copy from GitHub. There are complete instructions on how to use it in the included README file. Essentially though, all it takes is the installation of the small module, and inserting the following snippet into the footer of your site:

<a href="<?php echo Mage::helper('cls_designswitcher')->getMobileToDesktopUrl() ?>">View Desktop Site</a>

We are increasingly seeing a demand for responsive designs, but still get a lot of requests to simply build a separate mobile site as well, so I hope this will prove useful to some of you. Feedback, questions/comments are welcomed! Or if you have a mobile site (or responsive design) you need built, drop us a line via our contact page.

Contact Us