*/ class Mage_Sales_Model_Order_Status_History extends Mage_Sales_Model_Abstract { const CUSTOMER_NOTIFICATION_NOT_APPLICABLE = 2; /** * Order instance * * @var Mage_Sales_Model_Order */ protected $_order; /** * Whether setting order again is required (for example when setting non-saved yet order) * @deprecated after 1.4, wrong logic of setting order id * @var bool */ private $_shouldSetOrderBeforeSave = false; protected $_eventPrefix = 'sales_order_status_history'; protected $_eventObject = 'status_history'; /** * Initialize resource model */ protected function _construct() { $this->_init('sales/order_status_history'); } /** * Set order object and grab some metadata from it * * @param Mage_Sales_Model_Order $order * @return Mage_Sales_Model_Order_Status_History */ public function setOrder(Mage_Sales_Model_Order $order) { $this->_order = $order; $this->setStoreId($order->getStoreId()); return $this; } /** * Notification flag * * @param mixed $flag OPTIONAL (notification is not applicable by default) * @return Mage_Sales_Model_Order_Status_History */ public function setIsCustomerNotified($flag = null) { if (is_null($flag)) { $flag = self::CUSTOMER_NOTIFICATION_NOT_APPLICABLE; } return $this->setData('is_customer_notified', $flag); } /** * Customer Notification Applicable check method * * @return boolean */ public function isCustomerNotificationNotApplicable() { return $this->getIsCustomerNotified() == self::CUSTOMER_NOTIFICATION_NOT_APPLICABLE; } /** * Retrieve order instance * * @return Mage_Sales_Model_Order */ public function getOrder() { return $this->_order; } /** * Retrieve status label * * @return string */ public function getStatusLabel() { if($this->getOrder()) { return $this->getOrder()->getConfig()->getStatusLabel($this->getStatus()); } } /** * Get store object * * @return unknown */ public function getStore() { if ($this->getOrder()) { return $this->getOrder()->getStore(); } return Mage::app()->getStore(); } /** * Set order again if required * * @return Mage_Sales_Model_Order_Status_History */ protected function _beforeSave() { parent::_beforeSave(); if (!$this->getParentId() && $this->getOrder()) { $this->setParentId($this->getOrder()->getId()); } return $this; } }