0

this may seem a duplicate but I couldn't find one and been struggling with for quite some time now.

I'm extending Order Grid with a Column on Admin panel.

I have core_layout_block_create_after observer which, when called, addColumnAfter on $block = $observer->getBlock(); in my Observer's method:

 $block = $observer->getBlock();
    // how do I bind order id on this link
    $link = Mage::helper('adminhtml')->getUrl('adminhtml/mymodule/index');
    if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
        $block->addColumnAfter('action_cool_api',
            array(
                'header' => Mage::helper('adminhtml')->__('Cool Test'),
                'index' => 'action_cool_api',
                'type' => 'action',
                'actions'  => array(
                    array(
                        'url'     => $link,
                        'caption' => Mage::helper('adminhtml')->__('Cool'),
                    ),
                )
            ),
            'status'
        );
    }

How do I bind order id on every link?

1 Answer 1

1

Try this code :

<?php

$block = $observer->getBlock();
    // how do I bind order id on this link
    $link = array('base'=>'*/mymodule/index');
    if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
        $block->addColumnAfter('action_cool_api',
            array(
                'header' => Mage::helper('adminhtml')->__('Cool Test'),
                'index' => 'action_cool_api',
                'getter' => 'getId',
                'type' => 'action',
                'actions'  => array(
                    array(
                        'url'     => $link,
                        'caption' => Mage::helper('adminhtml')->__('Cool'),
                        'field'   => 'order_id',
                        'data-column' => 'action',
                    ),
                )
            ),
            'status'
        );
    }

Hope this work .

4
  • doesn't work. are you sure it's for Magento 1.9
    – popeye
    Commented Aug 14, 2018 at 14:17
  • i tried with real_order_id which is the real order column name, but it still didn't work
    – popeye
    Commented Aug 14, 2018 at 14:19
  • Yes it is , check app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid , methode : $this->addColumn which add the view action to the order grid. It should work the same way. Commented Aug 14, 2018 at 14:20
  • I am glad you could find the way to go :) , i have updated my answer as well :) . Commented Aug 14, 2018 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.