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);
1
  • is your issue solved?
    – zus
    Oct 5, 2017 at 11:17

1 Answer 1

0

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>
1
  • no explanation?
    – jstuardo
    Jul 29, 2021 at 21:25

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.