Witty and insightful observations on the world? Sorry to disappoint, this is a techie blog purely for self reference - published online in the hope it will help others!

Magento – Hide content based on IP address

This post will be useful to anybody who has been asked to hide or display Magento content (specifically prices and add to cart stuff) based on visitor IP. As a kickoff you can read my initial Stackoverflow question on it. I can't say who the client was (NDA) in this case but here's the synopsis; They are a UK based manufacturer and they don't want to compete with their worldwide supply chain, so they want; 1. All users with IPs originating in North America get redirected to a totally different website (non-Magento, nothing to do with me) ideally with a redirect message. 2. All user with IPs originating anywhere other than North America, The UK and ... Read more

Magento – displaying a custom attribute in a static block

Here's the scenario: I have used Template Master Easy Tabs in my Magento installation, it's working fine. I'm also using the Red Stage 'Shipping Price Per Product' extension so that the products can have their delivery individually priced (it's handmade hardwood furniture, so it need shipped by a removals firm rather than a courier/ delviery company). So there's a custom attribute called 'shipping_price' which is added to the default attribute set, and set to be able to be displayed on the front end. Easy tabs is very good, there is a section specifically allowing you to add an specified attribute to one of the tabs. There's also a different section allowing you to ... Read more

Adding a ‘New Product’ icon in Magento for new products

This is actually quick and easy but if you are new to Magento custom attributes you might struggle to work out how to set things up and then access the value of your attribute on the front end. What I am talking about here is setting up a flag for the product, if it's set to 'Yes' (ie the product is a new product) then a little icon or banner appears in the corner of the image. Like this; So, first things first. You need to set up a new Attribute in Catalogue -> Attributes -> Manage Attributes . Set is as a boolean, give it an id of new_product. ... Read more

Shopatron & Magento integration

At the moment I'm in in the middle of integrating a Magento installation with the Shopatron fulfilment and ordering system. Shopatron - so far I've decided that it sounds either like; Megatron's high maintenance Transformer mistress (who he wines and dines whilst poor old Mumatron is at home minding the Kidatrons). Magento vs Shopatron - that was Wrestlemania 7, right? Some kind of unscary android baddie from a cheap eighties Sci-Fi show, that maybe looks a bit like Metal Mickey or the aliens from the Smash adverts. Anyway, it's quite an interesting concept - basically it's a system which allows manufacturers to start selling online without cannibalising the sales in their distribution chain, pissing off off the retailer clients who they are ... Read more

Magento – Bulk Coupons and URL rewrites

I did the development work for the 2012 Queens Diamond Jubilee site, a Magento and Wordpress combination for Igniyte in Shipley (as I write I'm planning to do a case study about it, I'll make a note to come back and link to it here when I'm done). The site has been live for 5 months now and it's been really successful, shipping a lot of products globally and generally performing really well. Well enough that the mighty Vodafone decided to do a tie in with the site and offer a selection of products to their customers free. They needed: Free product cost and free delivery on one list of products. I needed to generate coupons in bulk, ... Read more

Magento – Displaying Products in a Static Block

This is one of those ones that can be a bit frustrating, there's many a tutorial out there that suggests you have to create a new template file and call that. It's possible to call the standard catalog/product/view.phtml template from a static block but also pass parameters which dictate how it's displayed. So you can add the following; And it will display the products using the default list template, with product numbers pulled from the System -> Configuration -> Catalog -> Frontend config. Better still, you can copy that template and rename it as a custom template, take out a lot of the grid/list and toolbar conditionals and style it up the ... Read more

Determining which Magento CMS page you are on

This post describes how to achieve what is effectively the same as the Wordpress is_page() method in Magento. Surprisingly I couldn't turn up much on Google about this, so thought it was worth a blog post on how I did it. I'm using a modified version of the jQuery backstretch plugin (posted here). I wanted the main product image to be shown as the background on each product page, but on CMS pages I wanted specific images to be displayed as the background for each page. The issue is that the Javscript for the backstretch is included in the head, so you need to be able to establish in templates/page/html/head.pthml whether you are on a product page ... Read more

prettyGallery & Magento

I really like the stuff that Stephane Caron does at No-Margin-For-Errors, he's published some awesome jQuery plugins. For my money prettyPhoto is the best lightbox out there, and I recently had need to put a small image slider in a Magento site for a client in West Yorkshire. The main Magento product image was to load in as a background image into a version of Scott Robbin's jQuery plugin Backstretch which I customised to work on a container rather than the body tag. The designs from the agency (who I can't mention - NDA) showed that additional images were loaded into a scrollable container further down the page, so I decided to use prettyGallery. ... Read more

prettyPhoto and Magento

********** EDIT - I just used prettyPhoto version 3.1.4 on a Magento site and it didn't need customised at all. The code had been refactored since this was originally written and now works slightly differently ************** If you Google 'PrettyPhoto Magento' there's not much coming up in the results (in Sept 2011). A whole dose of links to some paid-for extensions in Magento Connect which have dead links to the demo page, and links to a '360 degree' extension which contains a demo which doesn't seem to involve prettyPhoto. Hmmmph. So I suppose I better write one! Including prettyPhoto in Magento turned out to be prettyEasy, except for one important aspect which I'll cover at the end. Let's ... Read more