当前位置: 首页>>代码示例>>PHP>>正文


PHP Object::getEvent方法代码示例

本文整理汇总了PHP中Magento\Framework\Object::getEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getEvent方法的具体用法?PHP Object::getEvent怎么用?PHP Object::getEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Object的用法示例。


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

示例1: processTaxData

 /**
  * @param \Magento\Framework\Object $observer
  * @return \Magento\Quote\Model\Quote\Item
  */
 public function processTaxData($observer)
 {
     /** @var  \Magento\Quote\Model\Quote\Item $item */
     $item = $observer->getEvent()->getItem();
     $item->setRowTotal($this->getRowTotal($item))->setRowTotalInclTax($this->getRowTotalInclTax($item))->setPrice($this->getUnitDisplayPriceExclTax($item))->setPriceInclTax($this->getUnitDisplayPriceInclTax($item));
     return $item;
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:11,代码来源:Item.php

示例2: checkoutEventCreateGiftMessage

 /**
  * Operate with gift messages on checkout proccess
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function checkoutEventCreateGiftMessage($observer)
 {
     $giftMessages = $observer->getEvent()->getRequest()->getParam('giftmessage');
     $quote = $observer->getEvent()->getQuote();
     /* @var $quote \Magento\Sales\Model\Quote */
     if (is_array($giftMessages)) {
         foreach ($giftMessages as $entityId => $message) {
             $giftMessage = $this->_messageFactory->create();
             switch ($message['type']) {
                 case 'quote':
                     $entity = $quote;
                     break;
                 case 'quote_item':
                     $entity = $quote->getItemById($entityId);
                     break;
                 case 'quote_address':
                     $entity = $quote->getAddressById($entityId);
                     break;
                 case 'quote_address_item':
                     $entity = $quote->getAddressById($message['address'])->getItemById($entityId);
                     break;
                 default:
                     $entity = $quote;
                     break;
             }
             if ($entity->getGiftMessageId()) {
                 $giftMessage->load($entity->getGiftMessageId());
             }
             if (trim($message['message']) == '') {
                 if ($giftMessage->getId()) {
                     try {
                         $giftMessage->delete();
                         $entity->setGiftMessageId(0)->save();
                     } catch (\Exception $e) {
                     }
                 }
                 continue;
             }
             try {
                 $giftMessage->setSender($message['from'])->setRecipient($message['to'])->setMessage($message['message'])->save();
                 $entity->setGiftMessageId($giftMessage->getId())->save();
             } catch (\Exception $e) {
             }
         }
     }
     return $this;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:53,代码来源:Observer.php

示例3: sendEmail

 /**
  * @param \Magento\Framework\Object $observer
  *
  * @return void
  */
 public function sendEmail($observer)
 {
     /** @var  \Magento\Quote\Model\Quote $quote */
     $quote = $observer->getEvent()->getQuote();
     /** @var  \Magento\Sales\Model\Order $order */
     $order = $observer->getEvent()->getOrder();
     /**
      * a flag to set that there will be redirect to third party after confirmation
      */
     $redirectUrl = $quote->getPayment()->getOrderPlaceRedirectUrl();
     if (!$redirectUrl && $order->getCanSendNewEmailFlag()) {
         try {
             $this->orderSender->send($order);
         } catch (\Exception $e) {
             $this->logger->critical($e);
         }
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:23,代码来源:Submit.php

示例4: deleteProductGoogleExperimentScript

 /**
  * Delete Product scripts after deleting product
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function deleteProductGoogleExperimentScript($observer)
 {
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $observer->getEvent()->getProduct();
     $this->_modelCode->loadByEntityIdAndType($product->getId(), \Magento\GoogleOptimizer\Model\Code::ENTITY_TYPE_PRODUCT, $product->getStoreId());
     if ($this->_modelCode->getId()) {
         $this->_modelCode->delete();
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Delete.php

示例5: deleteCmsGoogleExperimentScript

 /**
  * Delete Product scripts after deleting product
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function deleteCmsGoogleExperimentScript($observer)
 {
     /** @var $cmsPage \Magento\Cms\Model\Page */
     $cmsPage = $observer->getEvent()->getObject();
     $this->_modelCode->loadByEntityIdAndType($cmsPage->getId(), \Magento\GoogleOptimizer\Model\Code::ENTITY_TYPE_PAGE);
     if ($this->_modelCode->getId()) {
         $this->_modelCode->delete();
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Delete.php

示例6: deleteCategoryGoogleExperimentScript

 /**
  * Delete Product scripts after deleting product
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function deleteCategoryGoogleExperimentScript($observer)
 {
     /** @var $category \Magento\Catalog\Model\Category */
     $category = $observer->getEvent()->getCategory();
     $this->_modelCode->loadByEntityIdAndType($category->getId(), \Magento\GoogleOptimizer\Model\Code::ENTITY_TYPE_CATEGORY, $category->getStoreId());
     if ($this->_modelCode->getId()) {
         $this->_modelCode->delete();
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Delete.php

示例7: checkoutSubmitAllAfter

 /**
  * Reset validation data
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function checkoutSubmitAllAfter($observer)
 {
     $method = false;
     if ($order = $observer->getEvent()->getOrder()) {
         $method = $order->getPayment()->getMethodInstance();
     } elseif ($orders = $observer->getEvent()->getOrders()) {
         if ($order = array_shift($orders)) {
             $method = $order->getPayment()->getMethodInstance();
         }
     }
     if ($method && $method->getIsCentinelValidationEnabled()) {
         $method->getCentinelValidator()->reset();
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:21,代码来源:Observer.php

示例8: deleteProductItem

 /**
  * Delete product item from Google Content
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function deleteProductItem($observer)
 {
     $product = $observer->getEvent()->getProduct();
     $items = $this->_getItemsCollection($product);
     try {
         $this->_operationsFactory->create()->deleteItems($items);
     } catch (\Zend_Gdata_App_CaptchaRequiredException $e) {
         $this->messageManager->addError('Cannot delete Google Content Item. Google requires CAPTCHA.');
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Observer.php

示例9: setLinkStatus

 /**
  * Set status of link
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function setLinkStatus($observer)
 {
     $order = $observer->getEvent()->getOrder();
     if (!$order->getId()) {
         //order not saved in the database
         return $this;
     }
     /* @var $order \Magento\Sales\Model\Order */
     $status = '';
     $linkStatuses = array('pending' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING, 'expired' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_EXPIRED, 'avail' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE, 'payment_pending' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING_PAYMENT, 'payment_review' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PAYMENT_REVIEW);
     $downloadableItemsStatuses = array();
     $orderItemStatusToEnable = $this->_scopeConfig->getValue(\Magento\Downloadable\Model\Link\Purchased\Item::XML_PATH_ORDER_ITEM_STATUS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $order->getStoreId());
     if ($order->getState() == \Magento\Sales\Model\Order::STATE_HOLDED) {
         $status = $linkStatuses['pending'];
     } elseif ($order->isCanceled() || $order->getState() == \Magento\Sales\Model\Order::STATE_CLOSED || $order->getState() == \Magento\Sales\Model\Order::STATE_COMPLETE) {
         $expiredStatuses = array(\Magento\Sales\Model\Order\Item::STATUS_CANCELED, \Magento\Sales\Model\Order\Item::STATUS_REFUNDED);
         foreach ($order->getAllItems() as $item) {
             if ($item->getProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE || $item->getRealProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
                 if (in_array($item->getStatusId(), $expiredStatuses)) {
                     $downloadableItemsStatuses[$item->getId()] = $linkStatuses['expired'];
                 } else {
                     $downloadableItemsStatuses[$item->getId()] = $linkStatuses['avail'];
                 }
             }
         }
     } elseif ($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) {
         $status = $linkStatuses['payment_pending'];
     } elseif ($order->getState() == \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW) {
         $status = $linkStatuses['payment_review'];
     } else {
         $availableStatuses = array($orderItemStatusToEnable, \Magento\Sales\Model\Order\Item::STATUS_INVOICED);
         foreach ($order->getAllItems() as $item) {
             if ($item->getProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE || $item->getRealProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
                 if ($item->getStatusId() == \Magento\Sales\Model\Order\Item::STATUS_BACKORDERED && $orderItemStatusToEnable == \Magento\Sales\Model\Order\Item::STATUS_PENDING && !in_array(\Magento\Sales\Model\Order\Item::STATUS_BACKORDERED, $availableStatuses, true)) {
                     $availableStatuses[] = \Magento\Sales\Model\Order\Item::STATUS_BACKORDERED;
                 }
                 if (in_array($item->getStatusId(), $availableStatuses)) {
                     $downloadableItemsStatuses[$item->getId()] = $linkStatuses['avail'];
                 }
             }
         }
     }
     if (!$downloadableItemsStatuses && $status) {
         foreach ($order->getAllItems() as $item) {
             if ($item->getProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE || $item->getRealProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
                 $downloadableItemsStatuses[$item->getId()] = $status;
             }
         }
     }
     if ($downloadableItemsStatuses) {
         $linkPurchased = $this->_createItemsCollection()->addFieldToFilter('order_item_id', array('in' => array_keys($downloadableItemsStatuses)));
         foreach ($linkPurchased as $link) {
             if ($link->getStatus() != $linkStatuses['expired'] && !empty($downloadableItemsStatuses[$link->getOrderItemId()])) {
                 $link->setStatus($downloadableItemsStatuses[$link->getOrderItemId()])->save();
             }
         }
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:65,代码来源:Observer.php

示例10: deleteBraintreeCustomer

 /**
  * Delete Braintree customer when Magento customer is deleted
  * 
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function deleteBraintreeCustomer(\Magento\Framework\Object $observer)
 {
     if (!$this->config->isActive()) {
         return $this;
     }
     $customer = $observer->getEvent()->getCustomer();
     $customerId = $this->helper->generateCustomerId($customer->getId(), $customer->getEmail());
     if ($this->vault->exists($customerId)) {
         $this->vault->deleteCustomer($customerId);
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:18,代码来源:Observer.php

示例11: setAttributeTabBlock

 /**
  * Setting attribute tab block for bundle
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function setAttributeTabBlock($observer)
 {
     $product = $observer->getEvent()->getProduct();
     if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
         $this->_helperCatalog->setAttributeTabBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes');
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Observer.php

示例12: salesEventConvertQuoteToOrder

 /**
  * Set gift messages to order from quote address
  *
  * @param \Magento\Framework\Object $observer
  * @return $this
  */
 public function salesEventConvertQuoteToOrder($observer)
 {
     $observer->getEvent()->getOrder()->setGiftMessageId($observer->getEvent()->getQuote()->getGiftMessageId());
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:Observer.php


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