/**
  * Save order into registry to use it in the overloaded controller.
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /* @var $order Order */
     $order = $this->coreRegistry->registry('directpost_order');
     if (!$order || !$order->getId()) {
         return $this;
     }
     $payment = $order->getPayment();
     if (!$payment || $payment->getMethod() != $this->payment->getCode()) {
         return $this;
     }
     $result = $observer->getData('result')->getData();
     if (!empty($result['error'])) {
         return $this;
     }
     // if success, then set order to session and add new fields
     $this->session->addCheckoutOrderIncrementId($order->getIncrementId());
     $this->session->setLastOrderIncrementId($order->getIncrementId());
     $requestToAuthorizenet = $payment->getMethodInstance()->generateRequestFromOrder($order);
     $requestToAuthorizenet->setControllerActionName($observer->getData('action')->getRequest()->getControllerName());
     $requestToAuthorizenet->setIsSecure((string) $this->storeManager->getStore()->isCurrentlySecure());
     $result[$this->payment->getCode()] = ['fields' => $requestToAuthorizenet->getData()];
     $observer->getData('result')->setData($result);
     return $this;
 }
Ejemplo n.º 2
0
 public function testSetEvent()
 {
     $event = 'someEvent';
     $this->observer->setEvent($event);
     $result = $this->observer->getData('event');
     $this->assertEquals($result, $this->observer->getEvent($event));
 }
Ejemplo n.º 3
0
 /**
  * @param Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $dirtyRules = $observer->getData('dirty_rules');
     if (!empty($dirtyRules)) {
         if ($dirtyRules->getState()) {
             $this->messageManager->addNotice($observer->getData('message'));
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function customerLoggedIn(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->weeeHelper->isEnabled()) {
         /** @var \Magento\Customer\Model\Data\Customer $customer */
         $customer = $observer->getData('customer');
         /** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
         $addresses = $customer->getAddresses();
         if (isset($addresses)) {
             $defaultShippingFound = false;
             $defaultBillingFound = false;
             foreach ($addresses as $address) {
                 if ($address->isDefaultBilling()) {
                     $defaultBillingFound = true;
                     $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($address->isDefaultShipping()) {
                     $defaultShippingFound = true;
                     $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($defaultShippingFound && $defaultBillingFound) {
                     break;
                 }
             }
         }
     }
 }
 /**
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(Observer $observer)
 {
     if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->taxHelper->isCatalogPriceDisplayAffectedByTax()) {
         /** @var \Magento\Customer\Model\Data\Customer $customer */
         $customer = $observer->getData('customer');
         $customerGroupId = $customer->getGroupId();
         $customerGroup = $this->groupRepository->getById($customerGroupId);
         $customerTaxClassId = $customerGroup->getTaxClassId();
         $this->customerSession->setCustomerTaxClassId($customerTaxClassId);
         /** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
         $addresses = $customer->getAddresses();
         if (isset($addresses)) {
             $defaultShippingFound = false;
             $defaultBillingFound = false;
             foreach ($addresses as $address) {
                 if ($address->isDefaultBilling()) {
                     $defaultBillingFound = true;
                     $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($address->isDefaultShipping()) {
                     $defaultShippingFound = true;
                     $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($defaultShippingFound && $defaultBillingFound) {
                     break;
                 }
             }
         }
     }
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Sales\Model\Order $order */
     $order = $observer->getData(self::DATA_ORDER);
     $this->_subRegister->savePv($order);
     $this->_subRegister->accountPv($order);
 }
Ejemplo n.º 7
0
 /**
  * Save quick styles
  *
  * @param EventObserver $event
  * @return void
  */
 public function saveQuickStyles($event)
 {
     /** @var $configuration \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration */
     $configuration = $event->getData('configuration');
     /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
     $theme = $event->getData('theme');
     if ($configuration->getControlConfig() instanceof \Magento\DesignEditor\Model\Config\Control\QuickStyles) {
         /** @var $renderer \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer */
         $renderer = $this->objectManager->create('Magento\\DesignEditor\\Model\\Editor\\Tools\\QuickStyles\\Renderer');
         $content = $renderer->render($configuration->getAllControlsData());
         /** @var $cssService \Magento\DesignEditor\Model\Theme\Customization\File\QuickStyleCss */
         $cssService = $this->objectManager->create('Magento\\DesignEditor\\Model\\Theme\\Customization\\File\\QuickStyleCss');
         /** @var $singleFile \Magento\Theme\Model\Theme\SingleFile */
         $singleFile = $this->objectManager->create('Magento\\Theme\\Model\\Theme\\SingleFile', ['fileService' => $cssService]);
         $singleFile->update($theme, $content);
     }
 }
 /**
  * @param EventObserver $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $storeId = $observer->getData('store')->getId();
     foreach ($this->entityPool->getEntities() as $entityType) {
         $this->sequenceBuilder->setPrefix($storeId)->setSuffix($this->sequenceConfig->get('suffix'))->setStartValue($this->sequenceConfig->get('startValue'))->setStoreId($storeId)->setStep($this->sequenceConfig->get('step'))->setWarningValue($this->sequenceConfig->get('warningValue'))->setMaxValue($this->sequenceConfig->get('maxValue'))->setEntityType($entityType)->create();
     }
     return $this;
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Framework\DataObject $input */
     $input = $observer->getData(self::DATA_INPUT);
     /** @var \Magento\Quote\Model\Quote\Payment $payment */
     $payment = $observer->getData(self::DATA_PAYMENT);
     assert($payment instanceof \Magento\Quote\Model\Quote\Payment);
     $quote = $payment->getQuote();
     /* see ./src/view/frontend/web/js/view/payment/method/partial.js */
     $usePartial = $input->getDataByPath('additional_data/use_partial');
     if (!is_null($usePartial)) {
         /* if JSON marker is set, we need set partial payment marker in quote */
         $quote->setData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::ATTR_QUOTE_SWITCH_PARTIAL_PAYMENT, (bool) $usePartial);
     } else {
         /* clear marker in quote */
         $quote->unsetData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::ATTR_QUOTE_SWITCH_PARTIAL_PAYMENT);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function execute(EventObserver $observer)
 {
     $action = $observer->getData('controller_action');
     if (is_object($action)) {
         $this->licenseFactory->create()->getStatus();
     }
     $feedModel = $this->feedFactory->create();
     $feedModel->checkUpdate();
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Customer\Model\Data\Customer $beforeSave */
     $beforeSave = $observer->getData('orig_customer_data_object');
     /** @var \Magento\Customer\Model\Data\Customer $afterSave */
     $afterSave = $observer->getData('customer_data_object');
     $idBefore = $beforeSave->getId();
     $idAfter = $afterSave->getId();
     if ($idBefore != $idAfter) {
         /* this is newly saved customer, register it into downline */
         $req = new \Praxigento\Downline\Service\Customer\Request\Add();
         $req->setCustomerId($idAfter);
         /* TODO: reference should be generated */
         $req->setReference($idAfter);
         $this->_callCustomer->add($req);
     }
     return;
 }
 /**
  * Set data for response of frontend saveOrder action
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     /* @var $order \Magento\Sales\Model\Order */
     $order = $this->_coreRegistry->registry('hss_order');
     if ($order && $order->getId()) {
         $payment = $order->getPayment();
         if ($payment && in_array($payment->getMethod(), $this->_paypalHss->getHssMethods())) {
             $result = $observer->getData('result')->getData();
             if (empty($result['error'])) {
                 $this->_view->loadLayout('checkout_onepage_review', true, true, false);
                 $html = $this->_view->getLayout()->getBlock('paypal.iframe')->toHtml();
                 $result['update_section'] = ['name' => 'paypaliframe', 'html' => $html];
                 $result['redirect'] = false;
                 $result['success'] = false;
                 $observer->getData('result')->setData($result);
             }
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * Extend UI blocks.
  * @param Varien_Event_Observer $observer
  */
 public function onAdminhtmlBlockHtmlBefore(\Magento\Framework\Event\Observer $observer)
 {
     if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
         $block = $observer->getData('block');
         if ($block instanceof Mage_Adminhtml_Block_Customer_Grid) {
             $this->doCustomerGridActionAdd($block);
         } elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
             $this->doOrderGridColumnAdd($block);
         }
     }
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /* Get base amount for partial payment from quote totals */
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $observer->getData(self::DATA_QUOTE);
     $basePartialAmount = $quote->getShippingAddress()->getData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::CODE_BASE_TOTAL);
     if ($basePartialAmount) {
         /* save amounts into order registry */
         $partialAmount = $quote->getShippingAddress()->getData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::CODE_TOTAL);
         /** @var \Magento\Sales\Model\Order $order */
         $order = $observer->getData(self::DATA_ORDER);
         $orderId = $order->getId();
         $data = new \Praxigento\Wallet\Data\Entity\Partial\Sale();
         $data->setPartialAmount($partialAmount);
         $data->setBasePartialAmount($basePartialAmount);
         $data->setSaleOrderRef($orderId);
         $this->_repoPartialSale->create($data);
         $this->_logger->debug("New partial payment by eWallet is registered for order #{$orderId} " . "(base: '{$basePartialAmount}', amount: '{$partialAmount}').");
     }
 }
Ejemplo n.º 15
0
 /**
  * Add Braintree PayPal shortcut buttons
  *
  * @param Observer $observer
  * @return void
  */
 public function execute(Observer $observer)
 {
     // Remove button from catalog pages
     if ($observer->getData('is_catalog_product')) {
         return;
     }
     /** @var ShortcutButtons $shortcutButtons */
     $shortcutButtons = $observer->getEvent()->getContainer();
     $shortcut = $shortcutButtons->getLayout()->createBlock(self::PAYPAL_SHORTCUT_BLOCK);
     $shortcutButtons->addShortcut($shortcut);
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Sales\Model\Order $order */
     $order = $observer->getData(self::DATA_ORDER);
     /* save PV for order and order items into the registry */
     $this->_subRegister->savePv($order);
     /* account PV if order is paid (credit card payment) */
     $state = $order->getState();
     $status = $order->getStatus();
     if ($state == \Magento\Sales\Model\Order::STATE_PROCESSING && $status != \Magento\Sales\Model\Order::STATUS_FRAUD) {
         $this->_subRegister->accountPv($order);
     }
 }
 /**
  * Modify the options config for the front end to resemble the weee final price
  *
  * @param   \Magento\Framework\Event\Observer $observer
  * @return  $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->weeeData->isEnabled()) {
         $priceConfigObj = $observer->getData('configObj');
         try {
             /** @var \Magento\Catalog\Model\Product $product */
             $product = $this->registry->registry('current_product');
             $weeeAttributesForBundle = $this->weeeData->getWeeeAttributesForBundle($product);
             $priceConfig = $this->recurConfigAndInsertWeeePrice($priceConfigObj->getConfig(), 'prices', $this->getWhichCalcPriceToUse($product->getStoreId(), $weeeAttributesForBundle), $weeeAttributesForBundle);
             $priceConfigObj->setConfig($priceConfig);
         } catch (\Exception $e) {
             return $this;
         }
     }
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * @param  EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     $data = $observer->getData();
     $orderId = $data['order_ids'][0];
     $orderData = $this->_quote->getOrderData($orderId);
     /* Now, lets update/create a target */
     $getResponseApi = $this->_restHelper->put('targets', $orderData);
     if (!isset($getResponseApi['result']['id'])) {
         /* Target creation/update failed */
         return 0;
     }
     $idSegement = $this->cfg->getConfig('checkoutSuccess/segment', 'none');
     if ($idSegement != 'none') {
         $endUrl = 'targets/' . $getResponseApi['result']['id'] . '/segments/' . $idSegement;
         $getResponseApi = $this->_restHelper->post($endUrl, null);
     }
 }
 /**
  * Modify the bundle config for the front end to resemble the tax included price when tax included prices
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->taxData->displayPriceIncludingTax()) {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $this->registry->registry('current_product');
         if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
             $priceConfigObj = $observer->getData('configObj');
             try {
                 $priceConfig = $this->recurConfigAndUpdatePrice($priceConfigObj->getConfig(), 'prices');
                 $priceConfigObj->setConfig($priceConfig);
             } catch (\Exception $e) {
                 return $this;
             }
         }
     }
     return $this;
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Sales\Model\Order $order */
     $order = $observer->getData(self::DATA_ORDER);
     $state = $order->getState();
     if ($state == \Magento\Sales\Model\Order::STATE_PROCESSING) {
         try {
             $this->_logger->debug("Call to Odoo service to replicate order.");
             $req = new \Praxigento\Odoo\Service\Replicate\Request\OrderSave();
             $req->setSaleOrder($order);
             $this->_callReplicate->orderSave($req);
         } catch (\Exception $e) {
             /* catch all exceptions and steal them */
             $msg = 'Some error is occurred on sale order saving to Odoo. Error: ' . $e->getMessage();
             $this->_logger->error($msg);
         }
     }
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Sales\Model\Order $order */
     $payment = $observer->getData(self::DATA_PAYMENT);
     assert($payment instanceof \Magento\Sales\Model\Order\Payment);
     $order = $payment->getOrder();
     $quoteId = $order->getQuoteId();
     $regQuote = $this->_repoPartialQuote->getById($quoteId);
     if ($regQuote) {
         $orderId = $order->getId();
         $customerId = $order->getCustomerId();
         $amount = $regQuote->getBasePartialAmount();
         $req = new \Praxigento\Wallet\Service\Operation\Request\PayForSaleOrder();
         $req->setOrderId($orderId);
         $req->setCustomerId($customerId);
         $req->setBaseAmountToPay($amount);
         $this->_callOperation->payForSaleOrder($req);
     }
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Sales\Model\Order\Invoice $invoice */
     $invoice = $observer->getData(self::DATA_INVOICE);
     $state = $invoice->getState();
     if ($state == \Magento\Sales\Model\Order\Invoice::STATE_PAID) {
         /* update date_paid in the PV registry */
         /** @var \Magento\Sales\Model\Order $order */
         $order = $invoice->getOrder();
         $orderId = $order->getEntityId();
         if ($orderId) {
             $datePaid = $this->_toolDate->getUtcNowForDb();
             $this->_logger->debug("Update paid date in PV registry on sale order (#{$orderId}) is paid.");
             $data = [ESale::ATTR_DATE_PAID => $datePaid];
             $this->_repoSale->updateById($orderId, $data);
             /* transfer PV to customer account */
             $this->_subRegister->accountPv($order);
         }
     }
 }
Ejemplo n.º 23
0
 /**
  * {@inheritdoc}
  *
  * @param EventObserver $observer
  */
 public function execute(EventObserver $observer)
 {
     /** @var \Magento\Framework\Data\Tree\Node $menu */
     $menu = $observer->getData('menu');
     $categories = $this->categoryCollectionFactory->create()->addAttributeToSelect(['name', 'url_key'])->excludeRoot()->addVisibilityFilter();
     $tree = $categories->getTree();
     $rootNode = new TreeNode(['id' => 'blog-node-root', 'name' => $this->config->getMenuTitle(), 'url' => $this->config->getBaseUrl()], 'id', $menu->getTree(), null);
     $menu->addChild($rootNode);
     foreach ($tree as $category) {
         if (isset($tree[$category->getParentId()])) {
             $parentNode = $tree[$category->getParentId()]->getData('node');
         } else {
             $parentNode = $rootNode;
         }
         $node = new TreeNode(['id' => 'blog-node-' . $category->getId(), 'name' => $category->getName(), 'url' => $category->getUrl()], 'id', $menu->getTree(), $parentNode);
         if ($parentNode) {
             $parentNode->addChild($node);
         } else {
             $menu->addChild($node);
         }
         $category->setData('node', $node);
     }
 }
Ejemplo n.º 24
0
 /**
  * @param \Magento\Framework\Event\Observer $observer
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $observerData = $observer->getData();
     $orderId = $observerData['orderId'];
     $shipmentData = $observerData['shipmentData'];
     $order = $this->coreModel->_getOrder($orderId);
     $method = $order->getShippingMethod();
     if ($this->shipmentHelper->isMercadoEnviosMethod($method)) {
         $methodId = $shipmentData['shipping_option']['shipping_method_id'];
         $name = $shipmentData['shipping_option']['name'];
         $order->setShippingMethod('mercadoenvios_' . $methodId);
         $estimatedDate = $this->_timezone->formatDate($shipmentData['shipping_option']['estimated_delivery']['date']);
         $estimatedDate = __('(estimated date %1)', $estimatedDate);
         $shippingDescription = 'MercadoEnvíos - ' . $name . ' ' . $estimatedDate;
         $order->setShippingDescription($shippingDescription);
         try {
             $order->save();
             $this->shipmentHelper->log('Order ' . $order->getIncrementId() . ' shipping data set ', $shipmentData);
         } catch (\Exception $e) {
             $this->shipmentHelper->log("error when update shipment data: " . $e);
             $this->shipmentHelper->log($e);
         }
     }
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Sales\Model\Order\Invoice $invoice */
     $invoice = $observer->getData(self::DATA_INVOICE);
     $state = $invoice->getState();
     if ($state == \Magento\Sales\Model\Order\Invoice::STATE_PAID) {
         try {
             /* update date_paid in the PV registry */
             /** @var \Magento\Sales\Model\Order $order */
             $order = $invoice->getOrder();
             $orderId = $order->getEntityId();
             $datePaid = $this->_toolDate->getUtcNowForDb();
             $this->_logger->debug("Update paid date in PV registry on sale order (#{$orderId}) is paid.");
             $data = [ESale::ATTR_DATE_PAID => $datePaid];
             $this->_repoSale->updateById($orderId, $data);
             /* transfer PV to customer account */
             $this->_subRegister->accountPv($order);
         } catch (\Throwable $e) {
             /* catch all exceptions and steal them */
             $msg = 'Some error is occurred on update of the paid date in PV register. Error: ' . $e->getMessage();
             $this->_logger->error($msg);
         }
     }
 }
 /**
  * Add a little text to the product.
  *
  * @param Observer $observer
  *
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Catalog\Model\Product $model */
     $model = $observer->getData('data_object');
     $model->setData('tudock_helloworld', 'Hello Observer!');
 }
Ejemplo n.º 27
0
 /**
  * Modify the options config for the front end to resemble the weee final price
  *
  * @param   \Magento\Framework\Event\Observer $observer
  * @return  $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getPriceConfiguration(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_weeeData->isEnabled()) {
         $priceConfigObj = $observer->getData('configObj');
         try {
             $product = $this->_registry->registry('current_product');
             $weeeAttributes = $this->_weeeData->getWeeAttributesForBundle($product);
             $calcPrice = 'finalPrice';
             if ($this->_taxData->priceIncludesTax() && $this->_taxData->displayPriceExcludingTax()) {
                 $calcPrice = 'basePrice';
             }
             $priceConfig = $this->recurConfigAndInsertWeeePrice($priceConfigObj->getConfig(), 'prices', $calcPrice, $weeeAttributes);
             $priceConfigObj->setConfig($priceConfig);
         } catch (\Exception $e) {
             return $this;
         }
     }
     return $this;
 }
Ejemplo n.º 28
0
 /**
  * Modify the options config for the front end to resemble the weee final price
  *
  * @param   \Magento\Framework\Event\Observer $observer
  * @return  $this
  */
 public function getPriceConfiguration(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_weeeData->isEnabled()) {
         $priceConfigObj = $observer->getData('configObj');
         $priceConfig = $priceConfigObj->getConfig();
         if (is_array($priceConfig)) {
             foreach ($priceConfig as $keyConfigs => $configs) {
                 if (is_array($configs)) {
                     if (array_key_exists('prices', $configs)) {
                         $priceConfig[$keyConfigs]['prices']['weeePrice'] = ['amount' => $configs['prices']['finalPrice']['amount']];
                     } else {
                         foreach ($configs as $keyConfig => $config) {
                             $priceConfig[$keyConfigs][$keyConfig]['prices']['weeePrice'] = ['amount' => $config['prices']['finalPrice']['amount']];
                         }
                     }
                 }
             }
         }
         $priceConfigObj->setConfig($priceConfig);
     }
     return $this;
 }
Ejemplo n.º 29
0
 /**
  * Modify the options config for the front end to resemble the weee final price
  *
  * @param   \Magento\Framework\Event\Observer $observer
  * @return  $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getPriceConfiguration(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_weeeData->isEnabled()) {
         $priceConfigObj = $observer->getData('configObj');
         $priceConfig = $priceConfigObj->getConfig();
         try {
             if (is_array($priceConfig)) {
                 foreach ($priceConfig as $keyConfigs => $configs) {
                     if (is_array($configs)) {
                         foreach ($configs as $keyConfig => $config) {
                             $calcPrice = 'finalPrice';
                             if ($this->_taxData->priceIncludesTax() && $this->_taxData->displayPriceExcludingTax()) {
                                 $calcPrice = 'basePrice';
                             }
                             if (array_key_exists('prices', $configs)) {
                                 $priceConfig[$keyConfigs]['prices']['weeePrice'] = ['amount' => $configs['prices'][$calcPrice]['amount']];
                             } else {
                                 foreach ($configs as $keyConfig => $config) {
                                     $priceConfig[$keyConfigs][$keyConfig]['prices']['weeePrice'] = ['amount' => $config['prices'][$calcPrice]['amount']];
                                 }
                             }
                         }
                     }
                 }
             }
             $priceConfigObj->setConfig($priceConfig);
         } catch (Exception $e) {
             return $this;
         }
     }
     return $this;
 }