Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:53:27+00:00 2026-05-26T11:53:27+00:00

I am working on a extension in which user enter different price for Stamp

  • 0

I am working on a extension in which user enter different price for ” Stamp Cost, Ink Cost,
Form Cost “. currently in data grid i am showing value of one field

$this->addColumn('stamp_cost', array(
    'header'    => Mage::helper('imprint')->__('Stamp Cost'),
    'width'     => '100px',
    'type'  => 'price',
    'currency_code' => $store->getBaseCurrency()->getCode(),
    'index'     => 'stamp_cost'
));

But Now I Need to show sum of all these fields in one column

How can we show sum of two fields in one column in magento admin data grid ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:53:28+00:00Added an answer on May 26, 2026 at 11:53 am

    Essentially, there are two ways to do it. Add the field to the collection and get the data from the database, or calculate it in PHP based on the 3 values returned from the DB. Doing the first way with the Magento Collection would, in my opinion, be too complex. instead, you want to use a Renderer (Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract)

    First, inside of the Block/Adminhtml folder of your plugin, make a new folder called Renderer. Inside of it make a new file called CostSum.php with the following contents:

    <?php 
    class Company_Module_Block_Adminhtml_Renderer_CostSum extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
    {
        public function render(Varien_Object $row)
        {
             return $row->getStampCost() + $row->getInkCost() + $row->getFormCost();
        }
    }
    

    Then, in the grid, make a new column

    $this->addColumn('cost_total', array(
        'header'    => Mage::helper('imprint')->__('Stamp Cost'),
        //'index'     => 'Im not sure this is necessary',
        'type'      => 'price',
        'currency_code' => $store->getBaseCurrency()->getCode(),
        'renderer' => new Company_Module_Block_Adminhtml_Renderer_CostSum() 
    ));
    

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Refresh() extension method for ObservableCollection which adds, removes or replaces
I am currently working on a Magento extension, and I have overridden a core
I'm working on a program that will sort files based on extension I currently
I'm am working on a little chrome extension which uses the contextMenu to add
I'm working on a project which makes heavy use of extension methods to convert
I'm currently working with some code involving saving a file to a user-defined file.
Im currently working with zend framework. Im working on a form to create a
I am working with an extension of the DefaultTableModel as follows: This is the
I'm working on an extension method that's only applicable to reference types. I think,
I'm working on a menu-generating HtmlHelper extension method. This method will need to know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.