1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Sales
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Enter description here ...
30: *
31: * @method Mage_Sales_Model_Resource_Order_Shipment_Comment _getResource()
32: * @method Mage_Sales_Model_Resource_Order_Shipment_Comment getResource()
33: * @method int getParentId()
34: * @method Mage_Sales_Model_Order_Shipment_Comment setParentId(int $value)
35: * @method int getIsCustomerNotified()
36: * @method Mage_Sales_Model_Order_Shipment_Comment setIsCustomerNotified(int $value)
37: * @method int getIsVisibleOnFront()
38: * @method Mage_Sales_Model_Order_Shipment_Comment setIsVisibleOnFront(int $value)
39: * @method string getComment()
40: * @method Mage_Sales_Model_Order_Shipment_Comment setComment(string $value)
41: * @method string getCreatedAt()
42: * @method Mage_Sales_Model_Order_Shipment_Comment setCreatedAt(string $value)
43: *
44: * @category Mage
45: * @package Mage_Sales
46: * @author Magento Core Team <core@magentocommerce.com>
47: */
48: class Mage_Sales_Model_Order_Shipment_Comment extends Mage_Sales_Model_Abstract
49: {
50: /**
51: * Shipment instance
52: *
53: * @var Mage_Sales_Model_Order_Shipment
54: */
55: protected $_shipment;
56:
57: /**
58: * Initialize resource model
59: */
60: protected function _construct()
61: {
62: $this->_init('sales/order_shipment_comment');
63: }
64:
65: /**
66: * Declare Shipment instance
67: *
68: * @param Mage_Sales_Model_Order_Shipment $shipment
69: * @return Mage_Sales_Model_Order_Shipment_Comment
70: */
71: public function setShipment(Mage_Sales_Model_Order_Shipment $shipment)
72: {
73: $this->_shipment = $shipment;
74: return $this;
75: }
76:
77: /**
78: * Retrieve Shipment instance
79: *
80: * @return Mage_Sales_Model_Order_Shipment
81: */
82: public function getShipment()
83: {
84: return $this->_shipment;
85: }
86:
87: /**
88: * Get store object
89: *
90: * @return Mage_Core_Model_Store
91: */
92: public function getStore()
93: {
94: if ($this->getShipment()) {
95: return $this->getShipment()->getStore();
96: }
97: return Mage::app()->getStore();
98: }
99:
100: /**
101: * Before object save
102: *
103: * @return Mage_Sales_Model_Order_Shipment_Comment
104: */
105: protected function _beforeSave()
106: {
107: parent::_beforeSave();
108:
109: if (!$this->getParentId() && $this->getShipment()) {
110: $this->setParentId($this->getShipment()->getId());
111: }
112:
113: return $this;
114: }
115: }
116: