- Canadian eCommerce (91)
- Canadian eCommerce Benchmark Quarterly Reports (5)
- Canadian eCommerce Monthly Trends (20)
- Careers (5)
- Design & User Experience (32)
- eCommerce (191)
- eCommerce Toronto Meetup (23)
- Email Marketing (1)
- Inbound Marketing (10)
- Infographics (47)
- Integration (1)
- Magento Commerce (90)
- Magento Extensions Updates (11)
- Mobile (11)
- Press Releases (1)
- Project Management (9)
- Ramblings (40)
- Search Engine Marketing (12)
- Search Engine Optimization (11)
- Site Launches (7)
- Social Media (16)
- This Week in eCommerce (14)
- [Infographic Wednesday] – The State of Canadian “Connectedness”
- An Analysis on Canadian Responsive Websites
- [Mini Tutorial] – How to get product attribute with getAttributeRawValue() in Magento
- This Week in eCommerce: May 13 – May 17
- 5 Ways Tablets & Mobile Devices Influence Design Trends
- [Infographic Wednesday] – 10 Ways to Increase Online Sales
- The Basics of Integration between Business Vision Essentials and Magento in C#
- New Site Launch: Books for Christ
- Are Canadian retailers ready for #responsive design websites? #ecommerce http://t.co/K9YX0PMbY8
- @walkerlucas sadly my schedule is pretty booked for the next 7 or so weeks. I may be at our next meetup tho. Could snag a few mins then.
- @mbertulli @blueacorn tried voodoo magic, cause Magento to turn into a oscommerce, 4/10 would not try again.
- RT @n_forten: Here is a great article on how #Responsive websites are optimal for multi-platform browsing #ecommerce via @demacmedia...
- Not a member of our #eCommerce #Toronto #Meetup group? Well you should be! Watch this video to find out why: http://t.co/sb5sHvOFun
- @demacmedia @blueacorn thx! Yeah for multiple app servers on a load-balancer I think REDIS might be the best option. I'll post my findings!
- @jayelkaake @blueacorn It depends on each client's needs, we have different solutions that include the use of memcache, redis and tmpfs
- @DiallogTelecom thanks for sharing!
[Mini Tutorial] – Magento Store Switcher as Country Flags
The following post is a quick tutorial to enable your Magento store switcher as country flags. We have included the code below to help you get started.
Related: Mini Tutorial -- How to use MYSQL String Functions to filter a Magento collection
You have two stores for countries US and Canada having store codes “us” and “ca” respectively.
This is the php* and html* code for the flag switches: <div class="store-countries">
<?php
$websites = Mage::getModel('core/website')->getCollection();
foreach($websites as $website):
$default_store = $website->getDefaultStore();
$url_obj = new Mage_Core_Model_Url();
$default_store_path = $url_obj->getBaseUrl(array('_store'=> $default_store->getCode()));
$current = strstr($this->helper('core/url')->getCurrentUrl(), $default_store_path);
if($default_store->getCode() == 'ca'){
$country = 'canada';
if(strstr($default_store_path,$this->helper('core/url')->getCurrentUrl())){
$current = true;
}?>
<a href="<?php if(!$current) echo $default_store_path; else echo '#' ?>" title="Shop in Canadian dollars"> </a>
<?php }
elseif($default_store->getCode() == 'us') {
$country = 'usa'; ?>
<a href="<?php if(!$current) echo $default_store_path; else echo '#' ?>" title="Shop in US dollars"> </a>
<?php }
?>
<?php endforeach; ?>
</div>
Here is the css*:
.store-countries { float: right }
.store-countries a {
display: block;
float: left;
height: 20px;
text-decoration: none;
width: 26px;
}
.store-countries a.current.canada {
background: url("../images/CAflag.jpg") no-repeat scroll 0 0 transparent;
}
.store-countries a.current.usa {
background: url("../images/USflag.jpg") no-repeat scroll 0 0 transparent;
}
.header-panel .store-countries a.not-current.canada {
background: url("../images/GreyCAflag.jpg") no-repeat scroll 0 0 transparent;
}
.store-countries a.not-current.usa {
background: url("../images/GreyUSflag.jpg") no-repeat scroll 0 0 transparent;
}
.store-countries a {
display: block;
float: left;
height: 20px;
text-decoration: none;
width: 26px;
}
.store-countries a.usa {
margin: 0 5px;
}
Required images (size: 26 x 20 px)
- GreyCAflag.jpg
- CAflag.jpg
- GreyUSflag.jpg
- USflag.jpg
* All coding was done by Michael Kreitzer
This entry was posted in Magento Commerce. Bookmark the permalink.






