本文整理匯總了PHP中Magento\Sales\Model\AbstractModel::_beforeSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractModel::_beforeSave方法的具體用法?PHP AbstractModel::_beforeSave怎麽用?PHP AbstractModel::_beforeSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::_beforeSave方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _beforeSave
/**
* Before object save manipulations
*
* @return $this
*/
protected function _beforeSave()
{
return parent::_beforeSave();
}
示例2: _beforeSave
/**
* Before object save manipulations
*
* @return $this
*/
protected function _beforeSave()
{
parent::_beforeSave();
if (!$this->getOrderId() && $this->getOrder()) {
$this->setOrderId($this->getOrder()->getId());
$this->setBillingAddressId($this->getOrder()->getBillingAddress()->getId());
}
return $this;
}
示例3: _beforeSave
/**
* Processing object before save data
*
* @return $this
*/
protected function _beforeSave()
{
parent::_beforeSave();
$this->_checkState();
if (!$this->getId()) {
$store = $this->getStore();
$name = array($store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName());
$this->setStoreName(implode("\n", $name));
}
if (!$this->getIncrementId()) {
$incrementId = $this->_eavConfig->getEntityType('order')->fetchNewIncrementId($this->getStoreId());
$this->setIncrementId($incrementId);
}
/**
* Process items dependency for new order
*/
if (!$this->getId()) {
$itemsCount = 0;
foreach ($this->getAllItems() as $item) {
$parent = $item->getQuoteParentItemId();
if ($parent && !$item->getParentItem()) {
$item->setParentItem($this->getItemByQuoteItemId($parent));
} elseif (!$parent) {
$itemsCount++;
}
}
// Set items count
$this->setTotalItemCount($itemsCount);
}
/** TODO refactor getCustomer usage after MAGETWO-20182 and MAGETWO-20258 are done */
$isNewCustomer = !$this->getCustomerId() || $this->getCustomerId() === true;
if ($isNewCustomer && $this->getCustomer()) {
$this->setCustomerId($this->getCustomer()->getId());
}
if ($this->hasBillingAddressId() && $this->getBillingAddressId() === null) {
$this->unsBillingAddressId();
}
if ($this->hasShippingAddressId() && $this->getShippingAddressId() === null) {
$this->unsShippingAddressId();
}
$this->setData('protect_code', substr(md5(uniqid(\Magento\Framework\Math\Random::getRandomNumber(), true) . ':' . microtime(true)), 5, 6));
return $this;
}
示例4: _beforeSave
/**
* Before object save
*
* @return $this
*/
protected function _beforeSave()
{
parent::_beforeSave();
if (!$this->getParentId() && $this->getInvoice()) {
$this->setParentId($this->getInvoice()->getId());
}
return $this;
}
示例5: _beforeSave
/**
* Before object save
*
* @return $this
* @throws \Magento\Framework\Model\Exception
*/
protected function _beforeSave()
{
if ((!$this->getId() || null !== $this->_items) && !count($this->getAllItems())) {
throw new \Magento\Framework\Model\Exception(__('We cannot create an empty shipment.'));
}
if (!$this->getOrderId() && $this->getOrder()) {
$this->setOrderId($this->getOrder()->getId());
$this->setShippingAddressId($this->getOrder()->getShippingAddress()->getId());
}
return parent::_beforeSave();
}