本文整理汇总了PHP中Mage_Sales_Model_Abstract::_beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Abstract::_beforeSave方法的具体用法?PHP Mage_Sales_Model_Abstract::_beforeSave怎么用?PHP Mage_Sales_Model_Abstract::_beforeSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Sales_Model_Abstract::_beforeSave方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Before object save
*
* @return Mage_Sales_Model_Order_Creditmemo_Comment
*/
protected function _beforeSave()
{
parent::_beforeSave();
if (!$this->getParentId() && $this->getCreditmemo()) {
$this->setParentId($this->getCreditmemo()->getId());
}
return $this;
}
示例2: _beforeSave
/**
* Before object save manipulations
*
* @return Mage_Sales_Model_Order_Creditmemo
*/
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 Mage_Core_Model_Abstract
*/
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 = Mage::getSingleton('eav/config')->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);
}
if ($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(mt_rand(), true) . ':' . microtime(true)), 5, 6));
return $this;
}
示例4: _beforeSave
/**
* Before object save
*
* @return Mage_Sales_Model_Order_Shipment
*/
protected function _beforeSave()
{
if ((!$this->getId() || null !== $this->_items) && !count($this->getAllItems())) {
Mage::throwException(Mage::helper('sales')->__('Cannot create an empty shipment.'));
}
if (!$this->getOrderId() && $this->getOrder()) {
$this->setOrderId($this->getOrder()->getId());
$this->setShippingAddressId($this->getOrder()->getShippingAddress()->getId());
}
if ($this->getPackages() && !is_scalar($this->getPackages())) {
$this->setPackages(serialize($this->getPackages()));
}
return parent::_beforeSave();
}
示例5: _beforeSave
/**
* Processing object before save data
*
* @return Mage_Core_Model_Abstract
*/
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));
}
/**
* Process items dependency for new order
*/
if (!$this->getId()) {
foreach ($this->getAllItems() as $item) {
if ($parent = $item->getQuoteParentItemId() && !$item->getParentItem()) {
$item->setParentItem($this->getItemByQuoteItemId($parent));
}
}
}
return $this;
}
示例6: _beforeSave
/**
* Processing object before save data
*
* @return Mage_Core_Model_Abstract
*/
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));
}
/**
* Process items dependency for new order
*/
if (!$this->getId()) {
foreach ($this->getAllItems() as $item) {
if ($parent = $item->getQuoteParentItemId() && !$item->getParentItem()) {
$item->setParentItem($this->getItemByQuoteItemId($parent));
}
}
}
if ($this->getCustomer()) {
$this->setCustomerId($this->getCustomer()->getId());
}
$this->setData('protect_code', substr(md5(uniqid(mt_rand(), true) . ':' . microtime(true)), 5, 6));
return $this;
}
示例7: _beforeSave
protected function _beforeSave()
{
if (!count($this->getAllItems())) {
Mage::throwException(Mage::helper('sales')->__('Cannot create an empty shipment.'));
}
return parent::_beforeSave();
}
示例8: _beforeSave
/**
* Set order again if required
* @return Mage_Sales_Model_Order_Status_History
*/
protected function _beforeSave()
{
if ($this->_shouldSetOrderBeforeSave) {
$this->setOrder($this->_order);
}
return parent::_beforeSave();
}