Get Store ID and Store Information

Use the following Magento code snippets in your site to retrieve information about the current store. The information can be very helpful if you are running a Magento multi-store setup where different elements of your store are only applicable to certain sites:




Get Country Name from Country Code

Just a quick snippet of code that will return you the Country Name based on a country code, e.g if you’re looking at the Order model getting the country_id of GB, however you need United Kingdom, the following code can be used: [code]Mage::app()->getLocale()->getCountryTranslation($country_id);[/code] Simply pass in your country id value (e.g GB) and Magento will […]



Adding Product Image Attributes

As standard Magneto ships with three Image attributes for products, these are: image, small_image and thumbnail. Though these are quite ample for most Magento stores, there may come a time when you need to add extra image attributes. Recently we had to add a extra image attribute to allow the client to add a swatch […]



Standalone Magento Scripts

Every now and again its useful to create a small standalone magento scripts, I have used them in the past to quickly update settings, or for creating small export scripts etc. These can be setup anywhere on the server and ran either in the browser or via the command line. Scripts would need to be […]



Drop Magento Database in One Query

The code below does as the title suggests. If anyone has been trying to remove the Magento database for whatever reason you’ll find that with all of the key constraints that come with Magento droping every table at once requires a special bit of code. Below is from a store, different version of Magento […]



Magento Zend Database Read Queries

As a platform Magento is built on the Zend Framework, therefore we can utilise the Zend Framework Database Class for reading from and writing to the Magento database. These actions would normally be used in a custom magento module or standalone script that you have running on your site. Direct database actions should be handled […]




Magento Robots.txt File

The robots.txt file on your website can help you say what gets indexed, crawled and used by the search engines. It is a vital part of your website which is often overlooked. Full details on the robots.txt file can be found on the wiki page @ http://en.wikipedia.org/wiki/Robots_exclusion_standard however below I have listed the most helpful […]



Get Customer Group from Session

Using the customer group is a good way to restrict and change parts of your Magento store when a customer is logged in. A good example of this is if you are wanting to put restrictions in or show alternative banners based on a Wholesaler customer login. To get the customer group id from the […]