• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Model\AbstractModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Sales\Model\AbstractModel的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel类的具体用法?PHP AbstractModel怎么用?PHP AbstractModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AbstractModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: build

 /**
  * {@inheritdoc}
  */
 public function build($type)
 {
     if ($this->isPaymentExists() && $this->transactionId !== null) {
         $transaction = $this->transactionRepository->getByTransactionId($this->transactionId, $this->payment->getId(), $this->order->getId());
         if (!$transaction) {
             $transaction = $this->transactionRepository->create()->setTxnId($this->transactionId);
         }
         $transaction->setPaymentId($this->payment->getId())->setPayment($this->payment)->setOrderId($this->order->getId())->setOrder($this->order)->setTxnType($type)->isFailsafe($this->failSafe);
         if ($this->payment->hasIsTransactionClosed()) {
             $transaction->setIsClosed((int) $this->payment->getIsTransactionClosed());
         }
         if ($this->transactionAdditionalInfo) {
             foreach ($this->transactionAdditionalInfo as $key => $value) {
                 $transaction->setAdditionalInformation($key, $value);
             }
         }
         $this->transactionAdditionalInfo = [];
         $this->payment->setLastTransId($transaction->getTxnId());
         $this->payment->setCreatedTransaction($transaction);
         $this->order->addRelatedObject($transaction);
         if ($this->document && $this->document instanceof AbstractModel) {
             $this->document->setTransactionId($transaction->getTxnId());
         }
         return $this->linkWithParentTransaction($transaction);
     }
     return null;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:30,代码来源:Builder.php


示例2: processRelation

 /**
  * Process relations for Shipment
  *
  * @param \Magento\Sales\Model\AbstractModel $object
  * @return void
  * @throws \Exception
  */
 public function processRelation(\Magento\Sales\Model\AbstractModel $object)
 {
     /** @var \Magento\Sales\Model\Order\Shipment $object */
     if (null !== $object->getItems()) {
         foreach ($object->getItems() as $item) {
             $item->setParentId($object->getId());
             $this->shipmentItemResource->save($item);
         }
     }
     if (null !== $object->getTracks()) {
         foreach ($object->getTracks() as $track) {
             $this->shipmentTrackResource->save($track);
         }
     }
     if (null !== $object->getComments()) {
         foreach ($object->getComments() as $comment) {
             $this->shipmentCommentResource->save($comment);
         }
     }
 }
开发者ID:kid17,项目名称:magento2,代码行数:27,代码来源:Relation.php


示例3: insertTotals

 /**
  * Insert totals to pdf page
  *
  * @param  \Zend_Pdf_Page $page
  * @param  \Magento\Sales\Model\AbstractModel $source
  * @return \Zend_Pdf_Page
  */
 protected function insertTotals($page, $source)
 {
     $order = $source->getOrder();
     $totals = $this->_getTotalsList();
     $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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:25,代码来源:AbstractPdf.php


示例4: _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 \Magento\Sales\Model\AbstractModel $salesDocument
  * @param bool $failsafe
  * @return null|Transaction
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 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 = $this->_transactionFactory->create()->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);
             }
             $this->_transactionAdditionalInfo = [];
         }
         // link with sales entities
         $this->setLastTransId($transactionId);
         $this->setCreatedTransaction($transaction);
         $this->getOrder()->addRelatedObject($transaction);
         if ($salesDocument && $salesDocument instanceof \Magento\Sales\Model\AbstractModel) {
             $salesDocument->setTransactionId($transactionId);
         }
         // 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;
     }
     return null;
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:77,代码来源:Payment.php


示例5: _afterSaveAttribute

 /**
  * After save object attribute
  *
  * @param AbstractModel $object
  * @param string $attribute
  * @return \Magento\Sales\Model\Resource\Attribute
  */
 protected function _afterSaveAttribute(AbstractModel $object, $attribute)
 {
     if ($object->getEventObject() && $object->getEventPrefix()) {
         $this->eventManager->dispatch($object->getEventPrefix() . '_save_attribute_after', [$object->getEventObject() => $this, 'object' => $object, 'attribute' => $attribute]);
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:14,代码来源:Attribute.php


示例6: testSyncRemove

 public function testSyncRemove()
 {
     $this->eventObserverMock->expects($this->once())->method('getDataObject')->willReturn($this->salesModelMock);
     $this->salesModelMock->expects($this->once())->method('getId')->willReturn('sales-id-value');
     $this->gridAggregatorMock->expects($this->once())->method('purge')->with('sales-id-value');
     $this->unit->execute($this->eventObserverMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:GridSyncRemoveObserverTest.php


示例7: testProcessRelations

 public function testProcessRelations()
 {
     $this->relationProcessorMock->expects($this->once())->method('processRelation')->with($this->salesModelMock);
     $this->salesModelMock->expects($this->once())->method('getEventPrefix')->willReturn('sales_event_prefix');
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with('sales_event_prefix_process_relation', ['object' => $this->salesModelMock]);
     $this->entityRelationComposite->processRelations($this->salesModelMock);
 }
开发者ID:kid17,项目名称:magento2,代码行数:7,代码来源:EntityRelationCompositeTest.php


示例8: testSyncInsert

 public function testSyncInsert()
 {
     $this->eventObserverMock->expects($this->once())->method('getObject')->willReturn($this->salesModelMock);
     $this->salesModelMock->expects($this->once())->method('getId')->willReturn('sales-id-value');
     $this->scopeConfigurationMock->expects($this->once())->method('getValue')->with('dev/grid/async_indexing', 'default', null)->willReturn(false);
     $this->gridAggregatorMock->expects($this->once())->method('refresh')->with('sales-id-value');
     $this->unit->execute($this->eventObserverMock);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:8,代码来源:GridSyncInsertObserverTest.php


示例9: testSaveFailed

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Expected Exception
  * @throws \Exception
  */
 public function testSaveFailed()
 {
     $this->modelMock->expects($this->any())->method('getEventPrefix')->will($this->returnValue('event_prefix'));
     $this->modelMock->expects($this->any())->method('getEventObject')->will($this->returnValue('event_object'));
     $this->appResourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($this->connectionMock));
     $exception = new \Exception('Expected Exception');
     $this->modelMock->expects($this->any())->method('getId')->will($this->throwException($exception));
     $this->connectionMock->expects($this->once())->method('beginTransaction');
     $this->connectionMock->expects($this->once())->method('rollback');
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with('event_prefix_save_attribute_before', ['event_object' => $this->attribute, 'object' => $this->modelMock, 'attribute' => ['attribute']]);
     $this->attribute->saveAttribute($this->modelMock, 'attribute');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:AttributeTest.php


示例10: getData

 /**
  * Retrieve data
  *
  * @param string $key
  * @param mixed $index
  * @return mixed
  */
 public function getData($key = '', $index = null)
 {
     if ('cc_number' === $key) {
         $ccNumber = parent::getData('cc_number');
         $ccNumberEnc = parent::getData('cc_number_enc');
         if (empty($ccNumber) && !empty($ccNumberEnc)) {
             $this->setData('cc_number', $this->decrypt($ccNumberEnc));
         }
     }
     if ('cc_cid' === $key) {
         $ccCid = parent::getData('cc_cid');
         $ccCidEnc = parent::getData('cc_cid_enc');
         if (empty($ccCid) && !empty($ccCidEnc)) {
             $this->setData('cc_cid', $this->decrypt($ccCidEnc));
         }
     }
     return parent::getData($key, $index);
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:25,代码来源:Info.php


示例11: _afterSave

 /**
  * Save order related objects
  *
  * @return $this
  */
 protected function _afterSave()
 {
     if (null !== $this->_addresses) {
         $this->_addresses->save();
         $billingAddress = $this->getBillingAddress();
         $attributesForSave = array();
         if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) {
             $this->setBillingAddressId($billingAddress->getId());
             $attributesForSave[] = 'billing_address_id';
         }
         $shippingAddress = $this->getShippingAddress();
         if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) {
             $this->setShippingAddressId($shippingAddress->getId());
             $attributesForSave[] = 'shipping_address_id';
         }
         if (!empty($attributesForSave)) {
             $this->_getResource()->saveAttribute($this, $attributesForSave);
         }
     }
     if (null !== $this->_items) {
         $this->_items->save();
     }
     if (null !== $this->_payments) {
         $this->_payments->save();
     }
     if (null !== $this->_statusHistory) {
         $this->_statusHistory->save();
     }
     foreach ($this->getRelatedObjects() as $object) {
         $object->save();
     }
     return parent::_afterSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:38,代码来源:Order.php


示例12: __construct

 /**
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  * @param AttributeValueFactory $customAttributeFactory
  * @param \Magento\Sales\Model\ResourceModel\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory
  * @param \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory $trackCollectionFactory
  * @param Shipment\CommentFactory $commentFactory
  * @param \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory
  * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
  * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  * @param array $data
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\ResourceModel\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory, \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory $trackCollectionFactory, \Magento\Sales\Model\Order\Shipment\CommentFactory $commentFactory, \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
 {
     $this->_shipmentItemCollectionFactory = $shipmentItemCollectionFactory;
     $this->_trackCollectionFactory = $trackCollectionFactory;
     $this->_commentFactory = $commentFactory;
     $this->_commentCollectionFactory = $commentCollectionFactory;
     $this->orderRepository = $orderRepository;
     parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, $data);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:24,代码来源:Shipment.php


示例13: __construct

 /**
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  * @param AttributeValueFactory $customAttributeFactory
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  * @param array $data
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __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 = [])
 {
     parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, $data);
     $this->_storeManager = $storeManager;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Comment.php


示例14: _afterSave

 /**
  * After object save manipulation
  *
  * @return $this
  */
 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();
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:23,代码来源:Invoice.php


示例15: _afterSave

 /**
  * After object save manipulations
  *
  * @return $this
  */
 protected function _afterSave()
 {
     if (null !== $this->_items) {
         foreach ($this->_items as $item) {
             $item->save();
         }
     }
     if (null !== $this->_tracks) {
         foreach ($this->_tracks as $track) {
             $track->save();
         }
     }
     if (null !== $this->_comments) {
         foreach ($this->_comments as $comment) {
             $comment->save();
         }
     }
     return parent::_afterSave();
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:24,代码来源:Shipment.php


示例16: __construct

 /**
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  * @param AttributeValueFactory $customAttributeFactory
  * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory
  * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  * @param array $data
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\Order\ItemFactory $orderItemFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
 {
     parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, $data);
     $this->_orderItemFactory = $orderItemFactory;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Item.php


示例17: _beforeDelete

 /**
  * Protect order delete from not admin scope
  * @return $this
  */
 protected function _beforeDelete()
 {
     return parent::_beforeDelete();
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:8,代码来源:Order.php


示例18: _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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Creditmemo.php


示例19: setData

 /**
  * Enforce format of the street field
  *
  * @param array|string $key
  * @param null $value
  * @return \Magento\Framework\DataObject
  */
 public function setData($key, $value = null)
 {
     if (is_array($key)) {
         $key = $this->implodeStreetField($key);
     } elseif ($key == OrderAddressInterface::STREET) {
         $value = $this->implodeStreetValue($value);
     }
     return parent::setData($key, $value);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Address.php


示例20: addData

 /**
  * Add data to the object.
  *
  * Retains previous data in the object.
  *
  * @param array $data
  * @return $this
  */
 public function addData(array $data)
 {
     if (array_key_exists('number', $data)) {
         $this->setNumber($data['number']);
         unset($data['number']);
     }
     return parent::addData($data);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:Track.php



注:本文中的Magento\Sales\Model\AbstractModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Model\Order类代码示例发布时间:2022-05-23
下一篇:
PHP Quote\Item类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap