*/ class Mage_XmlConnect_Block_Customer_Storecredit extends Mage_Core_Block_Template { /** * Render customer store credits xml * * @return string */ protected function _toHtml() { /** @var $xmlModel Mage_XmlConnect_Model_Simplexml_Element */ $xmlModel = Mage::getModel('xmlconnect/simplexml_element', ''); $accountBalance = $this->getLayout() ->addBlock('enterprise_customerbalance/account_balance', 'account_balance'); $xmlModel->addCustomChild('balance', null, array( 'label' => $this->__('Your current balance is:'), 'value' => $accountBalance->getBalance(), 'formatted_value' => Mage::helper('core')->currency($accountBalance->getBalance(), true, false) )); $accountHistory = $this->getLayout() ->addBlock('enterprise_customerbalance/account_history', 'account_history'); if ($accountHistory->canShow() && $accountHistory->getEvents() && count($accountHistory->getEvents())) { $balanceHistory = $xmlModel->addCustomChild('balance_history', null, array( 'label' => $this->__('Balance History'), 'action_label' => $this->__('Action'), 'balance_change_label' => $this->__('Balance Change'), 'balance_label' => $this->__('Balance'), 'date_label' => $this->__('Date') )); foreach ($accountHistory->getEvents() as $event) { $item = $balanceHistory->addCustomChild('item'); $item->addCustomChild('action', null, array( 'value' => $accountHistory->getActionLabel($event->getAction()) )); $item->addCustomChild('balance_change', null, array( 'value' => Mage::helper('core')->currency($event->getBalanceDelta(), true, false) )); $item->addCustomChild('balance', null, array( 'value' => Mage::helper('core')->currency($event->getBalanceAmount(), true, false) )); $item->addCustomChild('date', null, array( 'value' => Mage::helper('core')->formatDate($event->getUpdatedAt(), 'short', true) )); } } return $xmlModel->asNiceXml(); } }