Magento, grid, add column with link to a website

Magento, grid, add column with link to a website

August 2, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento, grid, add column with link to a website

Adding custom columns to your Magento admin grid can greatly enhance the user experience by providing quick access to relevant information directly from the grid view. However, when it comes to adding links to external websites within these custom columns, the process isn’t always straightforward.

In this guide, we’ll walk you through the step-by-step process of adding a new column to your Magento admin grid with a link to an external website using a custom renderer.

Understanding the Challenge

You’ve already made progress by following the Inchoo blog’s guide on how to add a custom renderer for a custom column in Magento. However, when you attempted to add a simple <a> tag within your render override, the link didn’t work as expected. This is because Magento doesn’t handle this scenario out-of-the-box.

The Solution: Overriding the Renderer

To achieve this, we need to override the default renderer behavior and manually create the HTML for our link. Let’s dive into the code:

Step 1: Define your custom column in the Grid.php file

protected function _prepareColumns()
{
    $this->addColumn('api_blog_url', array(
        'header' => $this->__('URL'),
        'align' => 'center',
        'index' => 'api_blog_url',
        'width' => 50,
        'type' => 'text',
        'renderer' => 'Dts_Blogtest_Block_Adminhtml_Blog_Renderer_CustomLink'
    ));
    // Rest of your code...
}

Notice that we’ve changed the render class to our custom one (Dts_Blogtest_Block_Adminhtml_Blog_Renderer_CustomLink).

Step 2: Create the Custom Link Renderer

Create a new file named CustomLink.php in the following directory:

app/code/local/Dts/Blogtest/Block/Adminhtml/Blog/Renderer/

In this file, define your custom renderer class:

<?php

class Dts_Blogtest_Block_Adminhtml_Blog_Renderer_CustomLink extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    public function render(Varien_Object $row)
    {
        $value =  $row->getData($this->getColumn()->getIndex());

        // Create the HTML for the link
        return '<a href="' . $value . '" target="_blank">' . $value . '</a>';
    }
}

In this renderer, we’re retrieving the column value and then manually creating an <a> tag with the href set to the column’s value. We’ve also added a target="_blank" attribute for better user experience.

Now, when you access your Magento admin grid, you should see the new ‘URL’ column populated with external links that point directly to the specified URLs in your data set.

This approach ensures that the links are rendered correctly and open in a new tab (due to target="_blank"), providing a seamless user experience for navigating between your Magento store and the linked websites.

Conclusion

Adding an external link column to your Magento admin grid is a powerful way to streamline workflows and provide quick access to relevant resources. By understanding how to override the default renderer behavior, you can achieve this functionality with relative ease.

This guide demonstrates not only how to implement this feature but also the thought process behind it—an important aspect of becoming proficient in Magento development.

Remember, when working with Magento, always strive for clean, maintainable code and keep an eye on best practices. If you’re looking for more advanced tips and tricks like this one, be sure to explore our Laravel Company blog, where we regularly publish insightful articles on Magento development.

Happy coding!

API Admin

Our network