1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class extends Mage_Core_Block_Template
35: {
36: protected function _construct()
37: {
38: 39: 40:
41: $this->setCacheKey('rss_order_status_'.$this->getRequest()->getParam('data'));
42: $this->setCacheLifetime(600);
43: }
44:
45: protected function _toHtml()
46: {
47: $rssObj = Mage::getModel('rss/rss');
48: $order = Mage::registry('current_order');
49: $title = Mage::helper('rss')->__('Order # %s Notification(s)',$order->getIncrementId());
50: $newurl = Mage::getUrl('sales/order/view',array('order_id' => $order->getId()));
51: $data = array('title' => $title,
52: 'description' => $title,
53: 'link' => $newurl,
54: 'charset' => 'UTF-8',
55: );
56: $rssObj->_addHeader($data);
57: $resourceModel = Mage::getResourceModel('rss/order');
58: $results = $resourceModel->getAllCommentCollection($order->getId());
59: if($results){
60: foreach($results as $result){
61: $urlAppend = 'view';
62: $type = $result['entity_type_code'];
63: if($type && $type!='order'){
64: $urlAppend = $type;
65: }
66: $type = Mage::helper('rss')->__(ucwords($type));
67: $title = Mage::helper('rss')->__('Details for %s #%s', $type, $result['increment_id']);
68:
69: $description = '<p>'.
70: Mage::helper('rss')->__('Notified Date: %s<br/>',$this->formatDate($result['created_at'])).
71: Mage::helper('rss')->__('Comment: %s<br/>',$result['comment']).
72: '</p>'
73: ;
74: $url = Mage::getUrl('sales/order/'.$urlAppend,array('order_id' => $order->getId()));
75: $data = array(
76: 'title' => $title,
77: 'link' => $url,
78: 'description' => $description,
79: );
80: $rssObj->_addEntry($data);
81: }
82: }
83: $title = Mage::helper('rss')->__('Order #%s created at %s', $order->getIncrementId(), $this->formatDate($order->getCreatedAt()));
84: $url = Mage::getUrl('sales/order/view',array('order_id' => $order->getId()));
85: $description = '<p>'.
86: Mage::helper('rss')->__('Current Status: %s<br/>',$order->getStatusLabel()).
87: Mage::helper('rss')->__('Total: %s<br/>',$order->formatPrice($order->getGrandTotal())).
88: '</p>'
89: ;
90: $data = array(
91: 'title' => $title,
92: 'link' => $url,
93: 'description' => $description,
94: );
95: $rssObj->_addEntry($data);
96: return $rssObj->createRssXml();
97: }
98: }
99: