Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
History Class Reference
Inheritance diagram for History:
AbstractModel OrderStatusHistoryInterface AbstractExtensibleModel ExtensibleDataInterface AbstractModel CustomAttributesDataInterface DataObject ExtensibleDataInterface

Public Member Functions

 __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=[])
 
 setOrder (\Magento\Sales\Model\Order $order)
 
 setIsCustomerNotified ($flag=null)
 
 isCustomerNotificationNotApplicable ()
 
 getOrder ()
 
 getStatusLabel ()
 
 getStore ()
 
 beforeSave ()
 
 getComment ()
 
 getCreatedAt ()
 
 setCreatedAt ($createdAt)
 
 getEntityId ()
 
 getEntityName ()
 
 getIsCustomerNotified ()
 
 getIsVisibleOnFront ()
 
 getParentId ()
 
 getStatus ()
 
 setParentId ($id)
 
 setIsVisibleOnFront ($isVisibleOnFront)
 
 setComment ($comment)
 
 setStatus ($status)
 
 setEntityName ($entityName)
 
 getExtensionAttributes ()
 
 setExtensionAttributes (\Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface $extensionAttributes)
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getEventObject ()
 
- Public Member Functions inherited from AbstractExtensibleModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getCustomAttributes ()
 
 getCustomAttribute ($attributeCode)
 
 setCustomAttributes (array $attributes)
 
 setCustomAttribute ($attributeCode, $attributeValue)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 setId ($value)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from OrderStatusHistoryInterface
 setEntityId ($entityId)
 
 setExtensionAttributes (\Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface $extensionAttributes)
 

Data Fields

const CUSTOMER_NOTIFICATION_NOT_APPLICABLE = 2
 
- Data Fields inherited from CustomAttributesDataInterface
const CUSTOM_ATTRIBUTES = 'custom_attributes'
 
- Data Fields inherited from ExtensibleDataInterface
const EXTENSION_ATTRIBUTES_KEY = 'extension_attributes'
 
- Data Fields inherited from OrderStatusHistoryInterface
const ENTITY_ID = 'entity_id'
 
const PARENT_ID = 'parent_id'
 
const IS_CUSTOMER_NOTIFIED = 'is_customer_notified'
 
const IS_VISIBLE_ON_FRONT = 'is_visible_on_front'
 
const COMMENT = 'comment'
 
const STATUS = 'status'
 
const CREATED_AT = 'created_at'
 
const ENTITY_NAME = 'entity_name'
 

Protected Member Functions

 _construct ()
 
- Protected Member Functions inherited from AbstractExtensibleModel
 filterCustomAttributes ($data)
 
 initializeCustomAttributes ()
 
 convertCustomAttributeValues (array &$customAttributes)
 
 getCustomAttributesCodes ()
 
 _setExtensionAttributes (\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
 
 _getExtensionAttributes ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_order
 
 $_eventPrefix = 'sales_order_status_history'
 
 $_eventObject = 'status_history'
 
 $_storeManager
 
- Protected Attributes inherited from AbstractExtensibleModel
 $extensionAttributesFactory
 
 $extensionAttributes
 
 $customAttributeFactory
 
 $customAttributesCodes = null
 
 $customAttributesChanged = false
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Order status history comments

@api @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Since
100.0.2

Definition at line 19 of file History.php.

Constructor & Destructor Documentation

◆ __construct()

__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 = [] 
)
Parameters
\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
\Magento\Framework\Data\Collection\AbstractDb$resourceCollection
array$data@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 56 of file History.php.

65  {
66  parent::__construct(
67  $context,
68  $registry,
69  $extensionFactory,
71  $resource,
72  $resourceCollection,
73  $data
74  );
75  $this->_storeManager = $storeManager;
76  }
$storeManager
$resource
Definition: bulk.php:12

Member Function Documentation

◆ _construct()

_construct ( )
protected

Initialize resource model

Returns
void

Definition at line 83 of file History.php.

84  {
85  $this->_init(\Magento\Sales\Model\ResourceModel\Order\Status\History::class);
86  }

◆ beforeSave()

beforeSave ( )

Set order again if required

Returns
$this

Definition at line 169 of file History.php.

170  {
171  parent::beforeSave();
172 
173  if (!$this->getParentId() && $this->getOrder()) {
174  $this->setParentId($this->getOrder()->getId());
175  }
176 
177  return $this;
178  }

◆ getComment()

getComment ( )

Returns comment

Returns
string

Implements OrderStatusHistoryInterface.

Definition at line 187 of file History.php.

◆ getCreatedAt()

getCreatedAt ( )

Returns created_at

Returns
string

Implements OrderStatusHistoryInterface.

Definition at line 197 of file History.php.

◆ getEntityId()

getEntityId ( )

Returns entity_id

Returns
int

Implements OrderStatusHistoryInterface.

Definition at line 215 of file History.php.

◆ getEntityName()

getEntityName ( )

Returns entity_name

Returns
string

Implements OrderStatusHistoryInterface.

Definition at line 225 of file History.php.

◆ getExtensionAttributes()

getExtensionAttributes ( )

{Retrieve existing extension attributes object or create a new one.

Returns
\Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface|null
}

Returns
\Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface|null

Implements OrderStatusHistoryInterface.

Definition at line 315 of file History.php.

◆ getIsCustomerNotified()

getIsCustomerNotified ( )

Returns is_customer_notified

Returns
int

Implements OrderStatusHistoryInterface.

Definition at line 235 of file History.php.

◆ getIsVisibleOnFront()

getIsVisibleOnFront ( )

Returns is_visible_on_front

Returns
int

Implements OrderStatusHistoryInterface.

Definition at line 245 of file History.php.

◆ getOrder()

getOrder ( )

Retrieve order instance

@codeCoverageIgnore

Returns
\Magento\Sales\Model\Order

Definition at line 133 of file History.php.

134  {
135  return $this->_order;
136  }

◆ getParentId()

getParentId ( )

Returns parent_id

Returns
int

Implements OrderStatusHistoryInterface.

Definition at line 255 of file History.php.

◆ getStatus()

getStatus ( )

Returns status

Returns
string

Implements OrderStatusHistoryInterface.

Definition at line 265 of file History.php.

◆ getStatusLabel()

getStatusLabel ( )

Retrieve status label

Returns
string|null

Definition at line 143 of file History.php.

144  {
145  if ($this->getOrder()) {
146  return $this->getOrder()->getConfig()->getStatusLabel($this->getStatus());
147  }
148  return null;
149  }

◆ getStore()

getStore ( )

Get store object

Returns
\Magento\Store\Model\Store

Definition at line 156 of file History.php.

157  {
158  if ($this->getOrder()) {
159  return $this->getOrder()->getStore();
160  }
161  return $this->_storeManager->getStore();
162  }

◆ isCustomerNotificationNotApplicable()

isCustomerNotificationNotApplicable ( )

Customer Notification Applicable check method

Returns
boolean

Definition at line 121 of file History.php.

◆ setComment()

setComment (   $comment)

{Sets the comment for the order status history.

Parameters
string$comment
Returns
$this
}

Implements OrderStatusHistoryInterface.

Definition at line 289 of file History.php.

◆ setCreatedAt()

setCreatedAt (   $createdAt)

{Sets the created-at timestamp for the order status history.

Parameters
string$createdAttimestamp
Returns
$this
}

Implements OrderStatusHistoryInterface.

Definition at line 205 of file History.php.

◆ setEntityName()

setEntityName (   $entityName)

{Sets the entity name for the order status history.

Parameters
string$entityName
Returns
$this
}

Implements OrderStatusHistoryInterface.

Definition at line 305 of file History.php.

◆ setExtensionAttributes()

setExtensionAttributes ( \Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface  $extensionAttributes)

{}

Parameters
\Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface$extensionAttributes
Returns
$this

Definition at line 326 of file History.php.

328  {
330  }
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)

◆ setIsCustomerNotified()

setIsCustomerNotified (   $flag = null)

Notification flag

Parameters
mixed$flagOPTIONAL (notification is not applicable by default)
Returns
$this

Implements OrderStatusHistoryInterface.

Definition at line 107 of file History.php.

108  {
109  if ($flag === null) {
111  }
112 
113  return $this->setData('is_customer_notified', $flag);
114  }

◆ setIsVisibleOnFront()

setIsVisibleOnFront (   $isVisibleOnFront)

{Sets the is-visible-on-storefront flag value for the order status history.

Parameters
int$isVisibleOnFront
Returns
$this
}

Implements OrderStatusHistoryInterface.

Definition at line 281 of file History.php.

◆ setOrder()

setOrder ( \Magento\Sales\Model\Order  $order)

Set order object and grab some metadata from it

Parameters
\Magento\Sales\Model\Order$order
Returns
$this

Definition at line 94 of file History.php.

95  {
96  $this->_order = $order;
97  $this->setStoreId($order->getStoreId());
98  return $this;
99  }
$order
Definition: order.php:55

◆ setParentId()

setParentId (   $id)

{Sets the parent ID for the order status history.

Parameters
int$id
Returns
$this
}

Implements OrderStatusHistoryInterface.

Definition at line 273 of file History.php.

◆ setStatus()

setStatus (   $status)

{Sets the status for the order status history.

Parameters
string$status
Returns
$this
}

Implements OrderStatusHistoryInterface.

Definition at line 297 of file History.php.

Field Documentation

◆ $_eventObject

$_eventObject = 'status_history'
protected

Definition at line 38 of file History.php.

◆ $_eventPrefix

$_eventPrefix = 'sales_order_status_history'
protected

Definition at line 33 of file History.php.

◆ $_order

$_order
protected

Definition at line 28 of file History.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 43 of file History.php.

◆ CUSTOMER_NOTIFICATION_NOT_APPLICABLE

const CUSTOMER_NOTIFICATION_NOT_APPLICABLE = 2

Definition at line 21 of file History.php.


The documentation for this class was generated from the following file: