1

I have created custom order attribute using following script.I want to show in sales order view screen below order status. and also if order is in hold only i want to show this attribute.

<?php
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
$attribute  = array(
'type'          => 'int',
'label'         => 'Is Notified',
'default'       => 0,
'visible'       => true,
'required'      => false,
'user_defined'  => true,
'comparable'    => false );

$installer->addAttribute('order', 'is_notified', $attribute);
  • is your issue solved? – zus Oct 5 '17 at 11:17
1

We can use event observer for this as below:

Observer code:

  /**
         * Hold Notified status display in admin order view
         * @param $observer
         */
        public function updateSalesOrderInfo($observer)
        {
            if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_View_Info) {
                $order = Mage::registry('sales_order');
                if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
                    $isNotified = $order->getData('is_notified');
                    $html = $observer->getTransport()->getHtml();
                    if ($isNotified) {
                        $html = str_replace('<span id="order_status">On Hold</span>', '<span id="order_status">On Hold</span><div>(Notified)</div>', $html);
                    } else {
                        $html = str_replace('<span id="order_status">On Hold</span>', '<span id="order_status">On Hold</span><div>(Not Notified)</div>', $html);
                    }

                    $observer->getTransport()->setData('html', $html);
                }
            }

  }

config.xml code

<events>
  <core_block_abstract_to_html_after>
      <observers>
          <update_sales_order_info>
              <model>orderholdnotify/observer</model>
              <method>updateSalesOrderInfo</method>
          </update_sales_order_info>
      </observers>
  </core_block_abstract_to_html_after>
</events>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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