Category archives: Programming




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:



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 […]



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 […]



Call a template from a Static Block

Recently I was searching for how to do this and all I could find was how to put a static block into your template file, however here is how to go the other way and pull a .phtml template file into a static block:

Simply replace the block type, block id and the template […]



Adding Custom Category Attributes

Through some recent work in the office we were required to add custom attributes to allow extra data entry via the category manager in the Magento admin area. We achived this by adding attributes in the SQL setup file from a custom module. Some examples of how to add these category attributes are shown below: […]



Get table name with prefix

When writing database queries in modules for Magento it is often helpful to wrap the table names in a core function called “getTableName” this function will then prefix the table name if the install is using prefixes in the database. To do this:



Quickly turn on PHP error reporting.

Some server environments by default do not have PHP error reporting turned on. If you have cPanel access or access to the PHP config on the server then you can switch the value and turn error reporting on, however this is not always practical/possible. Therefore here is a quick and easy way to turn error […]