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


PHP ManagerInterface::addException方法代码示例

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


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

示例1: execute

 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     try {
         $this->checkoutSession->loadCustomerQuote();
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Load customer quote error'));
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:LoadCustomerQuoteObserver.php

示例2: getWishlist

 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getWishlist($wishlistId = null)
 {
     if ($this->wishlist) {
         return $this->wishlist;
     }
     try {
         if (!$wishlistId) {
             $wishlistId = $this->request->getParam('wishlist_id');
         }
         $customerId = $this->customerSession->getCustomerId();
         $wishlist = $this->wishlistFactory->create();
         if (!$wishlistId && !$customerId) {
             return $wishlist;
         }
         if ($wishlistId) {
             $wishlist->load($wishlistId);
         } elseif ($customerId) {
             $wishlist->loadByCustomerId($customerId, true);
         }
         if (!$wishlist->getId() || $wishlist->getCustomerId() != $customerId) {
             throw new \Magento\Framework\Exception\NoSuchEntityException(__('The requested Wish List doesn\'t exist.'));
         }
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         $this->messageManager->addError($e->getMessage());
         return false;
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('We can\'t create the Wish List right now.'));
         return false;
     }
     $this->wishlist = $wishlist;
     return $wishlist;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:WishlistProvider.php

示例3: loadCustomerQuote

 /**
  * @return void
  */
 public function loadCustomerQuote()
 {
     try {
         $this->_checkoutSession->loadCustomerQuote();
     } catch (\Magento\Framework\Model\Exception $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Load customer quote error'));
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Observer.php

示例4: execute

 public function execute()
 {
     try {
         $order = $this->_getCheckoutSession()->getLastRealOrder();
         $method = $order->getPayment()->getMethod();
         $methodInstance = $this->_paymentHelper->getMethodInstance($method);
         if ($methodInstance instanceof \Paynl\Payment\Model\Paymentmethod\Paymentmethod) {
             $redirectUrl = $methodInstance->startTransaction($order, $this->_url);
             $this->_redirect($redirectUrl);
         } else {
             throw new Error('Method is not a paynl payment method');
         }
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Something went wrong, please try again later'));
         $this->_logger->critical($e);
         $this->_getCheckoutSession()->restoreQuote();
         $this->_redirect('checkout/cart');
     }
 }
开发者ID:paynl,项目名称:magento2-plugin,代码行数:19,代码来源:Redirect.php

示例5: execute

 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @throws \Exception
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $orderIds = $observer->getEvent()->getData('order_ids');
     if (isset($orderIds[0])) {
         $order = $this->orderRepository->get($orderIds[0]);
         if (!$order->getCustomerId()) {
             $isEmailAvailable = $this->accountManagement->isEmailAvailable($order->getCustomerEmail());
             //$this->logger->addInfo(print_r($isEmailAvailable,true));
             if ($isEmailAvailable) {
                 try {
                     $this->orderCustomerService->create($orderIds[0]);
                 } catch (\Exception $e) {
                     $this->messageManager->addException($e, $e->getMessage());
                     throw $e;
                 }
                 $this->coreRegistry->register('automatic_account', true);
             }
         }
     }
 }
开发者ID:sivajik34,项目名称:aac,代码行数:24,代码来源:AutomaticAccountCreateObserver.php

示例6: execute

 public function execute()
 {
     try {
         /** @var \Magento\Checkout\Model\Type\Onepage $onepage */
         $onepage = $this->_objectManager->get('Magento\\Checkout\\Model\\Type\\Onepage');
         /** @var \Magento\Quote\Model\Quote $quote */
         $quote = $onepage->getQuote();
         $quote->collectTotals();
         $quote->reserveOrderId();
         $orderId = $quote->getReservedOrderId();
         $payment = $quote->getPayment()->getMethodInstance();
         $total = $quote->getGrandTotal();
         $items = $quote->getAllVisibleItems();
         $currency = $quote->getQuoteCurrencyCode();
         $returnUrl = $this->_url->getUrl('paynl/finish/');
         $exchangeUrl = $this->_url->getUrl('paynl/exchange/');
         $paymentOptionId = $payment->getPaymentOptionId();
         $arrBillingAddress = $quote->getBillingAddress()->toArray();
         $arrShippingAddress = $quote->getShippingAddress()->toArray();
         $enduser = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname'], 'phoneNumber' => $arrBillingAddress['telephone'], 'emailAddress' => $arrBillingAddress['email']);
         $address = array();
         $arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']);
         $address['streetName'] = $arrAddress[0];
         $address['houseNumber'] = $arrAddress[1];
         $address['zipCode'] = $arrBillingAddress['postcode'];
         $address['city'] = $arrBillingAddress['city'];
         $address['country'] = $arrBillingAddress['country_id'];
         $shippingAddress = array();
         $arrAddress2 = \Paynl\Helper::splitAddress($arrShippingAddress['street']);
         $shippingAddress['streetName'] = $arrAddress2[0];
         $shippingAddress['houseNumber'] = $arrAddress2[1];
         $shippingAddress['zipCode'] = $arrShippingAddress['postcode'];
         $shippingAddress['city'] = $arrShippingAddress['city'];
         $shippingAddress['country'] = $arrShippingAddress['country_id'];
         $data = array('amount' => $total, 'returnUrl' => $returnUrl, 'paymentMethod' => $paymentOptionId, 'description' => $orderId, 'extra1' => $orderId, 'extra1' => $quote->getId(), 'exchangeUrl' => $exchangeUrl, 'currency' => $currency);
         $data['address'] = $address;
         $data['shippingAddress'] = $shippingAddress;
         $data['enduser'] = $enduser;
         $arrProducts = array();
         foreach ($items as $item) {
             $arrItem = $item->toArray();
             if ($arrItem['price_incl_tax'] != null) {
                 $product = array('id' => $arrItem['product_id'], 'name' => $arrItem['name'], 'price' => $arrItem['price_incl_tax'], 'qty' => $arrItem['qty'], 'tax' => $arrItem['tax_amount']);
             }
             $arrProducts[] = $product;
         }
         //shipping
         $shippingCost = $quote->getShippingAddress()->getShippingInclTax();
         $shippingTax = $quote->getShippingAddress()->getShippingTaxAmount();
         $shippingDescription = $quote->getShippingAddress()->getShippingDescription();
         $arrProducts[] = array('id' => 'shipping', 'name' => $shippingDescription, 'price' => $shippingCost, 'qty' => 1, 'tax' => $shippingTax);
         // kortingen
         $discount = $quote->getSubtotal() - $quote->getSubtotalWithDiscount();
         if ($discount > 0) {
             $arrProducts[] = array('id' => 'discount', 'name' => __('Discount'), 'price' => $discount * -1, 'qty' => 1, 'tax' => 0);
         }
         $data['products'] = $arrProducts;
         if ($this->_config->isTestMode()) {
             $data['testmode'] = 1;
         }
         $data['ipaddress'] = $quote->getRemoteIp();
         \Paynl\Config::setApiToken($this->_config->getApiToken());
         \Paynl\Config::setServiceId($this->_config->getServiceId());
         $transaction = \Paynl\Transaction::start($data);
         $onepage->saveOrder();
         $this->_redirect($transaction->getRedirectUrl());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Something went wrong, please try again later'));
         $this->_redirect('checkout/cart');
     }
 }
开发者ID:vkerkhoff,项目名称:magento2-plugin,代码行数:71,代码来源:Redirect.php


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