本文整理汇总了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'));
}
}
示例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;
}
示例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'));
}
}
示例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');
}
}
示例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);
}
}
}
}
示例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');
}
}