3

I want to show "Creation date" of an order in:

Sales -> Orders -> User -> Information -> Payment methods

At the moment I'm using this code:

class Company_Module_Block_Info extends Mage_Payment_Block_Info
{
    protected function _prepareSpecificInformation($transport = null)
    {
        if (null !== $this->_paymentSpecificInformation) {
            return $this->_paymentSpecificInformation;
        }

        $info = $this->getInfo();
        //Zend_Debug::dump($info); //List with created_at date

        $transport = new Varien_Object();
        $transport = parent::_prepareSpecificInformation($transport);
        $transport->addData(array(
            Mage::helper('payment')->__('Expiration date') => $info->getExpireDate(),
            Mage::helper('sales')->__('Creation date') => $info->getCreatedAt(),
            Mage::helper('payment')->__('Picked up by') => $info->getPickupCustomer()
        ));

        return $transport;
    }
}

The line which isn't working is this one:

Mage::helper('sales')->__('Creation date') => $info->getCreatedAt(),

At the moment it gives NULL, but I expect to return the custom creation date of the order (in format yyyy-mm-dd hh:mm:ss). When I use Mage::getModel('sales/order')->getCollection()->getFirstItem(); $order->getCreatedAt(); It returns the first created at date of the first order, but I need it for the selected order.

Does someone have any idea what is wrong?

  • Could you explain what isn't working? "The line which isn't working is this one". What do you expect it to do? What is happening now? Do you get any errors? – 7ochem Jun 29 '15 at 9:18
  • At the moment it gives NULL, but I expect to return the custom creation date of the order (in format yyyy-mm-dd hh:mm:ss). When I use Mage::getModel('sales/order')->getCollection()->getFirstItem(); $order->getCreatedAt(); It returns the first created at date of the first order, but I need it for the selected order. Thx – D_RBD Jun 29 '15 at 9:22
2

$info will hold an instance of Mage_Payment_Model_Info or Mage_Sales_Model_Order_Payment (which extends Mage_Payment_Model_Info)

The creation date that you want to get is the creation date of the actual sales order, but you are trying to get it from the info model.

If you would call $info->getOrder()->getCreatedAt() then that should work.

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.