|
27 | 27 | */
|
28 | 28 | class Mage_Sales_Model_Api2_Order_Comment_Rest_Admin_V1 extends Mage_Sales_Model_Api2_Order_Comment_Rest
|
29 | 29 | {
|
30 |
| - /** |
31 |
| - * Add comment to order |
32 |
| - * |
33 |
| - * @param array $data |
34 |
| - * @return string |
35 |
| - */ |
36 |
| - protected function _create(array $data) |
37 |
| - { |
38 |
| - $orderId = $this->getRequest()->getParam(self::PARAM_ORDER_ID); |
39 |
| - $order = $this->_loadOrderById($orderId); |
40 |
| - |
41 |
| - $status = $data['status'] ?? false; |
42 |
| - $comment = $data['comment'] ?? ''; |
43 |
| - $visibleOnFront = $data['is_visible_on_front'] ?? 0; |
44 |
| - $notifyCustomer = array_key_exists('is_customer_notified', $data) ? $data['is_customer_notified'] : false; |
45 |
| - |
46 |
| - $historyItem = $order->addStatusHistoryComment($comment, $status); |
47 |
| - $historyItem->setIsCustomerNotified($notifyCustomer) |
48 |
| - ->setIsVisibleOnFront((int) $visibleOnFront) |
49 |
| - ->save(); |
50 |
| - |
51 |
| - try { |
52 |
| - $oldStore = Mage::getDesign()->getStore(); |
53 |
| - $oldArea = Mage::getDesign()->getArea(); |
54 |
| - |
55 |
| - if ($notifyCustomer && $comment) { |
56 |
| - Mage::getDesign()->setStore($order->getStoreId()); |
57 |
| - Mage::getDesign()->setArea('frontend'); |
58 |
| - } |
59 |
| - |
60 |
| - $order->save(); |
61 |
| - $order->sendOrderUpdateEmail((bool) $notifyCustomer, $comment); |
62 |
| - |
63 |
| - if ($notifyCustomer && $comment) { |
64 |
| - Mage::getDesign()->setStore($oldStore); |
65 |
| - Mage::getDesign()->setArea($oldArea); |
66 |
| - } |
67 |
| - } catch (Mage_Core_Exception $e) { |
68 |
| - $this->_critical($e->getMessage(), self::RESOURCE_INTERNAL_ERROR); |
69 |
| - } catch (Throwable $t) { |
70 |
| - Mage::logException($t); |
71 |
| - $this->_critical($t->getMessage(), self::RESOURCE_UNKNOWN_ERROR); |
72 |
| - } |
73 |
| - |
74 |
| - return $this->_getLocation($historyItem); |
75 |
| - } |
76 |
| - |
77 |
| - /** |
78 |
| - * Retrieve order comment by id |
79 |
| - * |
80 |
| - * @return array |
81 |
| - */ |
82 |
| - protected function _retrieve() |
83 |
| - { |
84 |
| - $comment = Mage::getModel('sales/order_status_history')->load( |
85 |
| - $this->getRequest()->getParam(self::PARAM_COMMENT_ID) |
86 |
| - ); |
87 |
| - |
88 |
| - if (!$comment->getId()) { |
89 |
| - $this->_critical(self::RESOURCE_NOT_FOUND); |
90 |
| - } |
91 |
| - |
92 |
| - return $comment->getData(); |
93 |
| - } |
94 | 30 | }
|
0 commit comments