Magento Themes and Magento Extensions

Adding Custom Attributes to the Manage Products Admin Grid

Posted on March 7th, 2013 | Posted by admin

In magento: I was asked by a client if I could add a custom attribute to the admin manage products grid/list. They were spending a load of time clicking into each product just to see the attribute. Here is how I added it to the grid.

Copy app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php to

At around line 62 add the attribute you want to select to the collection:

Programmatically Setting a Magento Item’s Price When Adding It to Cart

Posted on February 3rd, 2013 | Posted by admin

Using code, how would we give a Magento item a one-time special price then add that item to the shopping cart?

The process is simple:

  • Create an instance of the Magento product,
    • give it a custom price by calling setSpecialPrice,
    • then save the product instance (store must be running as the admin store).
  • Next, grab the Magento cart object (a singleton),
    • add the product instance to the cart,
    • then save the cart.

Adding New Arrivals to Magento

Posted on December 9th, 2012 | Posted by admin

So, Tridian has been doing quite a bit of Magento development work lately, and in keeping with the spirit of “open source” software, we thought we’d share a module that we recently developed that addresses a very common need when creating an e-store with Magento. The requirements are to get the X most recently products added to the store (108 in this case) and display them in their own “New Arrivals” category, but make it so that the cart will automatically display the newest products based on the product’s creation date, without the site admin having to manually assigned them into and out of a “New Arrivals” category.

In order to create “New Arrivals” functionality on my client’s Magento store (which is 1.1.6, but this code also works for all versions of Magento through the current, I created the following module. My approach was to override the normal category behavior for my “New Arrivals” category and display a custom product collection instead.

Step 1: In the admin, create a category called “New Arrivals” and leave it empty.

Step 2: Find the code that generates the product listings on the Category pages. Turns out the code that does this is in the class Mage_Catalog_Block_Product_List. Great. But now, in order to get the cart to do what we want, we have to override this class and add my own custom code to handle the creation of the product collection for the empty category “New Arrivals”. To do this, I created a new block file called Tridian_Newarrivals_Block_Newarrivals, which extends the original, and saved it here: app/code/local/Tridian/Newarrivals/Block/Newarrivals.php.


Posted on November 28th, 2012 | Posted by admin

This is an issue I come across from time to time, especially when using wordpress or anything else that dynamically produces content.

The scenario is you have a list of posts on a page and you’re not able to add a class to the last item in the list (say to remove a separating border).

One option would be to to use the pseudo css class :last-child in your css e.g:


This would then remove the border on the last post div, which is a nice simple fix. The only downside is that :last-child doesn’t work in IE7+8 (surprise surprise).

So here is a nice simple jQuery fix to the problem.

Adding an additional content block to your Magento page

Posted on November 13th, 2012 | Posted by admin

It turns out that once you understand Magento’s complicated template layout structure it becomes pretty easy to add content blocks wherever your website needs them. This is just a quick explanation of how that works.

So first things first, find your page layout file. This will be under the app design folder in your themes layout folder and will be named page.xml. This file contins an element called default that (in magento terms) is called a Hook. A hook represents a page, or page type – in this case the default hook is the layout for any page that hasn’t got it’s own specific hook. Usually everything will be defined in here and then the other hooks will add and remove blocks, rather than starting from scratch each time. Inside the hook element you will then find a number of blocks, the most interesting to us are the header and footer blocks. There are other blocks defined but the header and footer are the bext example as they are built using their own templates and contain both specific blocks and a block that can have other blocks added to it (a text_list). Following the same way those blocks work we want to define a block that in our design will go after our pages main content but before the footer. Lets start with the basics…

1 <block type="core/text_list" name="content.footer" as="content_footer" translate="label">
2 <label>Content Footer</label>
3 </block>
Page 1 of 212»