Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
History.php
Go to the documentation of this file.
1 <?php
7 
11 
20 {
22 
28  protected $_order;
29 
33  protected $_eventPrefix = 'sales_order_status_history';
34 
38  protected $_eventObject = 'status_history';
39 
43  protected $_storeManager;
44 
56  public function __construct(
57  \Magento\Framework\Model\Context $context,
58  \Magento\Framework\Registry $registry,
59  \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
62  \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
63  \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
64  array $data = []
65  ) {
66  parent::__construct(
67  $context,
68  $registry,
69  $extensionFactory,
71  $resource,
72  $resourceCollection,
73  $data
74  );
75  $this->_storeManager = $storeManager;
76  }
77 
83  protected function _construct()
84  {
85  $this->_init(\Magento\Sales\Model\ResourceModel\Order\Status\History::class);
86  }
87 
94  public function setOrder(\Magento\Sales\Model\Order $order)
95  {
96  $this->_order = $order;
97  $this->setStoreId($order->getStoreId());
98  return $this;
99  }
100 
107  public function setIsCustomerNotified($flag = null)
108  {
109  if ($flag === null) {
111  }
112 
113  return $this->setData('is_customer_notified', $flag);
114  }
115 
122  {
124  }
125 
133  public function getOrder()
134  {
135  return $this->_order;
136  }
137 
143  public function getStatusLabel()
144  {
145  if ($this->getOrder()) {
146  return $this->getOrder()->getConfig()->getStatusLabel($this->getStatus());
147  }
148  return null;
149  }
150 
156  public function getStore()
157  {
158  if ($this->getOrder()) {
159  return $this->getOrder()->getStore();
160  }
161  return $this->_storeManager->getStore();
162  }
163 
169  public function beforeSave()
170  {
171  parent::beforeSave();
172 
173  if (!$this->getParentId() && $this->getOrder()) {
174  $this->setParentId($this->getOrder()->getId());
175  }
176 
177  return $this;
178  }
179 
180  //@codeCoverageIgnoreStart
181 
187  public function getComment()
188  {
190  }
191 
197  public function getCreatedAt()
198  {
200  }
201 
205  public function setCreatedAt($createdAt)
206  {
207  return $this->setData(OrderStatusHistoryInterface::CREATED_AT, $createdAt);
208  }
209 
215  public function getEntityId()
216  {
218  }
219 
225  public function getEntityName()
226  {
228  }
229 
235  public function getIsCustomerNotified()
236  {
238  }
239 
245  public function getIsVisibleOnFront()
246  {
248  }
249 
255  public function getParentId()
256  {
258  }
259 
265  public function getStatus()
266  {
268  }
269 
273  public function setParentId($id)
274  {
276  }
277 
281  public function setIsVisibleOnFront($isVisibleOnFront)
282  {
283  return $this->setData(OrderStatusHistoryInterface::IS_VISIBLE_ON_FRONT, $isVisibleOnFront);
284  }
285 
289  public function setComment($comment)
290  {
291  return $this->setData(OrderStatusHistoryInterface::COMMENT, $comment);
292  }
293 
297  public function setStatus($status)
298  {
300  }
301 
305  public function setEntityName($entityName)
306  {
307  return $this->setData(OrderStatusHistoryInterface::ENTITY_NAME, $entityName);
308  }
309 
315  public function getExtensionAttributes()
316  {
317  return $this->_getExtensionAttributes();
318  }
319 
326  public function setExtensionAttributes(
327  \Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface $extensionAttributes
328  ) {
329  return $this->_setExtensionAttributes($extensionAttributes);
330  }
331 
332  //@codeCoverageIgnoreEnd
333 }
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
Definition: History.php:56
$id
Definition: fieldset.phtml:14
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
$order
Definition: order.php:55
$storeManager
$resource
Definition: bulk.php:12
setOrder(\Magento\Sales\Model\Order $order)
Definition: History.php:94
$status
Definition: order_status.php:8
setIsVisibleOnFront($isVisibleOnFront)
Definition: History.php:281
setExtensionAttributes(\Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface $extensionAttributes)
Definition: History.php:326