本文整理汇总了PHP中Magento\Sales\Model\AbstractModel::beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::beforeSave方法的具体用法?PHP AbstractModel::beforeSave怎么用?PHP AbstractModel::beforeSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Sales\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::beforeSave方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Verify data required for saving
*
* @return $this
*/
public function beforeSave()
{
if (!$this->getOrderId() && $this->getOrder()) {
$this->setOrderId($this->getOrder()->getId());
}
if (!$this->getPaymentId() && $this->getOrder() && $this->getOrder()->getPayment()) {
$this->setPaymentId($this->getOrder()->getPayment()->getId());
}
// set parent id
$this->_verifyPaymentObject();
if (!$this->getId()) {
$this->setCreatedAt($this->_dateFactory->create()->gmtDate());
}
return parent::beforeSave();
}
示例2: beforeSave
/**
* Verify data required for saving
*
* @return $this
*/
public function beforeSave()
{
// set parent id
$this->_verifyPaymentObject();
if (!$this->getId()) {
// We need to set order and payment ids only for new transactions
if (null !== $this->_paymentObject) {
$this->setPaymentId($this->_paymentObject->getId());
}
if (null !== $this->_order) {
$this->setOrderId($this->_order->getId());
}
$this->setCreatedAt($this->_dateFactory->create()->gmtDate());
}
return parent::beforeSave();
}
示例3: beforeSave
/**
* Set order again if required
*
* @return $this
*/
public function beforeSave()
{
parent::beforeSave();
if (!$this->getParentId() && $this->getOrder()) {
$this->setParentId($this->getOrder()->getId());
}
return $this;
}