本文整理汇总了PHP中Mage_Sales_Model_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Abstract类的具体用法?PHP Mage_Sales_Model_Abstract怎么用?PHP Mage_Sales_Model_Abstract使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Sales_Model_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractAdditionalParams
/**
* @param Mage_Sales_Model_Abstract $itemContainer
* @return array
*/
public function extractAdditionalParams(Mage_Sales_Model_Abstract $itemContainer = null)
{
$invoice = null;
if ($itemContainer instanceof Mage_Sales_Model_Order_Invoice && $itemContainer) {
$invoice = $itemContainer;
} else {
if ($itemContainer instanceof Mage_Sales_Block_Order_Creditmemo && $itemContainer) {
$invoice = Mage::getModel('sales/order_invoice')->load($itemContainer->getInvoiceId());
}
}
if ($invoice == null) {
// if invoice is not set we load id hard from the request params
$invoice = $this->getRefundHelper()->getInvoiceFromCreditMemoRequest();
}
$this->creditmemo = $this->getRefundHelper()->getCreditMemoFromRequest();
if ($invoice instanceof Mage_Sales_Model_Order_Invoice) {
$this->extractFromCreditMemoItems($invoice);
// We dont extract from discount data for the moment, because partial refunds are a problem
// $this->extractFromDiscountData($invoice);
$this->extractFromInvoicedShippingMethod($invoice);
$this->extractFromAdjustments($invoice);
// Overwrite amount to fix Magentos rounding problems (eg +1ct)
$this->additionalParams['AMOUNT'] = $this->amount;
}
return $this->additionalParams;
}
示例2: getAllOrderItems
/**
* @param Mage_Sales_Model_Abstract $entity
* @param Mage_Sales_Model_Order $order
* @param string $context
*
* @return mixed
*/
protected function getAllOrderItems($entity, $order, $context)
{
$this->_order = $order;
if ($context == self::TYPE_RS) {
return $entity->getAllItems();
}
return $order->getAllItems();
}
示例3: _getTotalsList
/**
* Return total list
*
* @param Mage_Sales_Model_Abstract $source
* @return array
*/
protected function _getTotalsList($source)
{
$nodeName = Mage::helper('zab_billing')->getTotalConfigPath($source->getTipo());
$totals = Mage::getConfig()->getNode($nodeName)->asArray();
usort($totals, array($this, '_sortTotalsList'));
$totalModels = array();
foreach ($totals as $index => $totalInfo) {
if (!empty($totalInfo['model'])) {
$totalModel = Mage::getModel($totalInfo['model']);
if ($totalModel instanceof Mage_Sales_Model_Order_Pdf_Total_Default) {
$totalInfo['model'] = $totalModel;
} else {
Mage::throwException(Mage::helper('sales')->__('PDF total model should extend Mage_Sales_Model_Order_Pdf_Total_Default'));
}
} else {
$totalModel = Mage::getModel($this->_defaultTotalModel);
}
$totalModel->setData($totalInfo);
$totalModels[] = $totalModel;
}
return $totalModels;
}
示例4: insertAddressesAndHeader
/**
* insert customer address and all header like customer number, etc.
*
* @param Zend_Pdf_Page $page current Zend_Pdf_Page
* @param Mage_Sales_Model_Abstract $source source for the address information
* @param Mage_Sales_Model_Order $order order to print the document for
*/
protected function insertAddressesAndHeader(Zend_Pdf_Page $page, Mage_Sales_Model_Abstract $source, Mage_Sales_Model_Order $order)
{
// Add logo
$this->insertLogo($page, $source->getStore());
// Add billing address
$this->y = 692 - $this->_marginTop;
$this->_insertCustomerAddress($page, $order);
// Add sender address
$this->y = 705 - $this->_marginTop;
$this->_insertSenderAddessBar($page);
// Add head
$this->y = 592 - $this->_marginTop;
$this->insertHeader($page, $order, $source);
/* Add table head */
// make sure that item table does not overlap heading
if ($this->y > 575 - $this->_marginTop) {
$this->y = 575 - $this->_marginTop;
}
}
示例5: _addTransaction
/**
* Create transaction,
* prepare its insertion into hierarchy and add its information to payment and comments
*
* To add transactions and related information,
* the following information should be set to payment before processing:
* - transaction_id
* - is_transaction_closed (optional) - whether transaction should be closed or open (closed by default)
* - parent_transaction_id (optional)
* - should_close_parent_transaction (optional) - whether to close parent transaction (closed by default)
*
* If the sales document is specified, it will be linked to the transaction as related for future usage.
* Currently transaction ID is set into the sales object
* This method writes the added transaction ID into last_trans_id field of the payment object
*
* To make sure transaction object won't cause trouble before saving, use $failsafe = true
*
* @param string $type
* @param Mage_Sales_Model_Abstract $salesDocument
* @param bool $failsafe
* @return null|Mage_Sales_Model_Order_Payment_Transaction
*/
protected function _addTransaction($type, $salesDocument = null, $failsafe = false)
{
if ($this->getSkipTransactionCreation()) {
$this->unsTransactionId();
return null;
}
// look for set transaction ids
$transactionId = $this->getTransactionId();
if (null !== $transactionId) {
// set transaction parameters
$transaction = false;
if ($this->getOrder()->getId()) {
$transaction = $this->_lookupTransaction($transactionId);
}
if (!$transaction) {
$transaction = Mage::getModel('sales/order_payment_transaction')->setTxnId($transactionId);
}
$transaction->setOrderPaymentObject($this)->setTxnType($type)->isFailsafe($failsafe);
if ($this->hasIsTransactionClosed()) {
$transaction->setIsClosed((int) $this->getIsTransactionClosed());
}
//set transaction addition information
if ($this->_transactionAdditionalInfo) {
foreach ($this->_transactionAdditionalInfo as $key => $value) {
$transaction->setAdditionalInformation($key, $value);
}
}
// link with sales entities
$this->setLastTransId($transactionId);
$this->setCreatedTransaction($transaction);
$this->getOrder()->addRelatedObject($transaction);
if ($salesDocument && $salesDocument instanceof Mage_Sales_Model_Abstract) {
$salesDocument->setTransactionId($transactionId);
// TODO: linking transaction with the sales document
}
// link with parent transaction
$parentTransactionId = $this->getParentTransactionId();
if ($parentTransactionId) {
$transaction->setParentTxnId($parentTransactionId);
if ($this->getShouldCloseParentTransaction()) {
$parentTransaction = $this->_lookupTransaction($parentTransactionId);
if ($parentTransaction) {
if (!$parentTransaction->getIsClosed()) {
$parentTransaction->isFailsafe($failsafe)->close(false);
}
$this->getOrder()->addRelatedObject($parentTransaction);
}
}
}
return $transaction;
}
}
示例6: insertTotals
/**
* Insert totals to pdf page
*
* @param Zend_Pdf_Page $page
* @param Mage_Sales_Model_Abstract $source
* @return Zend_Pdf_Page
*/
protected function insertTotals($page, $source)
{
$order = $source->getOrder();
$totals = $this->_getTotalsList($source);
$lineBlock = array('lines' => array(), 'height' => 15);
foreach ($totals as $total) {
$total->setOrder($order)->setSource($source);
if ($total->canDisplay()) {
$total->setFontSize(10);
foreach ($total->getTotalsForDisplay() as $totalData) {
$lineBlock['lines'][] = array(array('text' => $totalData['label'], 'feed' => 475, 'align' => 'right', 'font_size' => $totalData['font_size'], 'font' => 'bold'), array('text' => $totalData['amount'], 'feed' => 565, 'align' => 'right', 'font_size' => $totalData['font_size'], 'font' => 'bold'));
}
}
}
$this->y -= 20;
$page = $this->drawLineBlocks($page, array($lineBlock));
return $page;
}
示例7: salesOrderEntitySaveBefore
/**
* Check whether order entity may be saved
*
* Invoice, shipment, creditmemo (address & item?)
*
* @param Mage_Sales_Model_Abstract $model
*/
public function salesOrderEntitySaveBefore($model)
{
$this->_salesEntitySaveBefore(Mage::app()->getStore($model->getOrder()->getStoreId())->getWebsiteId());
}
示例8: insertTotals
/**
* Insert totals to pdf page
*
* @param Zend_Pdf_Page $page
* @param Mage_Sales_Model_Abstract $source
* @return Zend_Pdf_Page
*/
protected function insertTotals($page, $source)
{
// remvoeme
$this->y += 40;
if ($this->y - 150 < 15) {
$page = $this->newPage($pageSettings);
}
$order = $source->getOrder();
$totals = $this->_getTotalsList($source);
$lineBlock = array('lines' => array(), 'height' => 20);
$this->y -= 30;
$page->setFillColor(new Zend_Pdf_Color_Html("#58a300"));
$page->setLineColor(new Zend_Pdf_Color_GrayScale(1));
$page->setLineWidth(0.5);
$page->drawRectangle(275, $this->y, 570, $this->y - 30);
$this->_setFontBold($page, 12);
$page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
$page->drawText(Mage::helper('sales')->__('Betrag'), 285, $this->y - 20, 'UTF-8');
$this->sy = $this->y;
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
$this->y -= 30;
foreach ($totals as $total) {
$total->setOrder($order)->setSource($source);
if ($total->canDisplay()) {
$total->setFontSize(10);
foreach ($total->getTotalsForDisplay() as $totalData) {
$fontSize = 7;
if ("Gesamt (inkl. Steuern):" === $totalData["label"]) {
$fontSize = 10;
}
if (false !== strpos($totalData["label"], "Produkte zu 19")) {
continue;
}
if ("Steuer:" === $totalData["label"]) {
$totalData["label"] = "19% MwSt.";
}
$totalData["label"] = str_replace("Steuern", "MwSt.", $totalData["label"]);
$lineBlock['lines'][] = array(array('text' => $totalData['label'], 'feed' => 475, 'align' => 'right', "font_size" => 7, 'font' => 'bold'), array('text' => $totalData['amount'], 'feed' => 525, 'align' => 'right', "font_size" => $fontSize, 'font' => 'bold'));
}
}
}
$this->y -= 20;
$page = $this->drawLineBlocks($page, array($lineBlock));
return $page;
}
示例9: insertTotals
/**
* Insert totals to pdf page
*
* @param Zend_Pdf_Page $page
* @param Mage_Sales_Model_Abstract $source
* @return Zend_Pdf_Page
*/
protected function insertTotals($page, $source)
{
$order = $source->getOrder();
$totals = $this->_getTotalsList($source);
$lineBlock = array('lines' => array(), 'height' => 15);
foreach ($totals as $total) {
$total->setOrder($order)->setSource($source);
if ($total->canDisplay()) {
$total->setFontSize(10);
foreach ($total->getTotalsForDisplay() as $totalData) {
if (isset($totalData['title']) && strpos($totalData['title'], '%') !== false) {
$origLabel = $totalData['label'];
$totalData['label'] = trim(preg_replace('/\\s*\\([^)]*\\)/', '', $origLabel));
#echo "<pre/>";print_r($totalData);die;
}
Mage::log(print_r($totalData, true), NULL, 'developerTotalAfter.log');
$lineBlock['lines'][] = array(array('text' => $totalData['label'], 'feed' => 475, 'align' => 'right', 'font_size' => $totalData['font_size'], 'font' => 'bold'), array('text' => $totalData['amount'], 'feed' => 565, 'align' => 'right', 'font_size' => $totalData['font_size'], 'font' => 'bold'));
}
}
}
$this->y -= 20;
$page = $this->drawLineBlocks($page, array($lineBlock));
return $page;
}
示例10: _addTransaction
/**
* Create transaction, prepare its insertion into hierarchy and add its information to payment and comments
*
* To add transactions and related information, the following information should be set to payment before processing:
* - transaction_id
* - is_transaction_closed (optional) - whether transaction should be closed or open (closed by default)
* - parent_transaction_id (optional)
* - should_close_parent_transaction (optional) - whether to close parent transaction (closed by default)
*
* If the sales document is specified, it will be linked to the transaction as related for future usage.
* Currently transaction ID is set into the sales object
* This method writes the added transaction ID into last_trans_id field of the payment object
*
* To make sure transaction object won't cause trouble before saving, use $failsafe = true
*
* @param Mage_Sales_Model_Order_Payment
* @param string $type
* @param Mage_Sales_Model_Abstract $salesDocument
* @param bool $failsafe
* @return null|Mage_Sales_Model_Order_Payment_Transaction
*/
protected function _addTransaction($payment, $type, $salesDocument = null, $failsafe = false)
{
// look for set transaction ids
$transactionId = $payment->getTransactionId();
if (null !== $transactionId) {
// set transaction parameters
/*$transaction = Mage::getModel('sales/order_payment_transaction')
->setOrderPaymentObject($payment)
->setTxnType($type)
->setTxnId($transactionId)
->isFailsafe($failsafe)
;*/
// set transaction parameters
//$transaction = false;
$transaction = $this->_lookupTransaction($payment, $transactionId);
if (!$transaction) {
$transaction = Mage::getModel('sales/order_payment_transaction')->setTxnId($transactionId);
}
$transaction->setOrderPaymentObject($payment)->setTxnType($type)->isFailsafe($failsafe);
if ($payment->hasIsTransactionClosed()) {
$transaction->setIsClosed((int) $payment->getIsTransactionClosed());
}
// link with sales entities
$payment->setLastTransId($transactionId);
$payment->setCreatedTransaction($transaction);
$payment->getOrder()->addRelatedObject($transaction);
if ($salesDocument && $salesDocument instanceof Mage_Sales_Model_Abstract) {
$salesDocument->setTransactionId($transactionId);
// TODO: linking transaction with the sales document
}
// link with parent transaction Not used because transaction Id is the same
$parentTransactionId = $payment->getParentTransactionId();
if ($parentTransactionId) {
$transaction->setParentTxnId($parentTransactionId);
if ($payment->getShouldCloseParentTransaction()) {
$parentTransaction = $this->_lookupTransaction($payment, $parentTransactionId);
//
if ($parentTransaction) {
$parentTransaction->isFailsafe($failsafe)->close(false);
$payment->getOrder()->addRelatedObject($parentTransaction);
}
}
}
return $transaction;
}
}
示例11: fetchNewIncrementId
/**
* @param Mage_Sales_Model_Abstract $object
* @return string
*/
protected function fetchNewIncrementId(Mage_Sales_Model_Abstract $object)
{
$entityTypeModel = $this->getFactory()->getModelEavEntityType();
$code = '';
if ($object instanceof Mage_Sales_Model_Order_Invoice) {
$code = 'invoice';
} elseif ($object instanceof Mage_Sales_Model_Order_Creditmemo) {
$code = 'creditmemo';
}
$entityType = $entityTypeModel->loadByCode($code);
$newIncrementId = $entityType->fetchNewIncrementId($this->getStoreId());
if ($newIncrementId !== false) {
$object->setIncrementId($newIncrementId);
}
return $newIncrementId;
}
示例12: setCustomFields
/**
* @param Mage_Customer_Model_Address_Abstract|Mage_Sales_Model_Abstract $magentoObject
* @param ShopgateOrder|ShopgateAddress|ShopgateCustomer $shopgateObject
* @return mixed
*/
public function setCustomFields($magentoObject, $shopgateObject)
{
foreach ($shopgateObject->getCustomFields() as $field) {
$magentoObject->setData($field->getInternalFieldName(), $field->getValue());
}
return $magentoObject;
}
示例13: _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;
}
示例14: _afterSave
/**
* After object save manipulation
*
* @return Mage_Sales_Model_Order_Shipment
*/
protected function _afterSave()
{
if (null !== $this->_items) {
/**
* Save invoice items
*/
foreach ($this->_items as $item) {
$item->setOrderItem($item->getOrderItem());
$item->save();
}
}
if (null !== $this->_comments) {
foreach ($this->_comments as $comment) {
$comment->save();
}
}
return parent::_afterSave();
}
示例15: addData
/**
* Add data to the object.
*
* Retains previous data in the object.
*
* @param array $data
* @return Mage_Sales_Model_Order_Shipment_Track
*/
public function addData(array $data)
{
if (array_key_exists('number', $data)) {
$this->setNumber($data['number']);
unset($data['number']);
}
return parent::addData($data);
}