Beispiel #1
0
 /**
  * Generate options for currency displaying with custom currency symbol
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function currencyDisplayOptions(\Magento\Framework\Event\Observer $observer)
 {
     $baseCode = $observer->getEvent()->getBaseCode();
     $currencyOptions = $observer->getEvent()->getCurrencyOptions();
     $currencyOptions->setData($this->_currencySymbolData->getCurrencyOptions($baseCode));
     return $this;
 }
 /**
  * Generate options for currency displaying with custom currency symbol
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $baseCode = $observer->getEvent()->getBaseCode();
     $currencyOptions = $observer->getEvent()->getCurrencyOptions();
     $currencyOptions->setData($this->getCurrencyOptions($baseCode));
     return $this;
 }
 /**
  * Check move quote item to wishlist request
  *
  * @param   Observer $observer
  * @return  $this
  */
 public function execute(Observer $observer)
 {
     $cart = $observer->getEvent()->getCart();
     $data = $observer->getEvent()->getInfo()->toArray();
     $productIds = [];
     $wishlist = $this->getWishlist($cart->getQuote()->getCustomerId());
     if (!$wishlist) {
         return $this;
     }
     /**
      * Collect product ids marked for move to wishlist
      */
     foreach ($data as $itemId => $itemInfo) {
         if (!empty($itemInfo['wishlist']) && ($item = $cart->getQuote()->getItemById($itemId))) {
             $productId = $item->getProductId();
             $buyRequest = $item->getBuyRequest();
             if (array_key_exists('qty', $itemInfo) && is_numeric($itemInfo['qty'])) {
                 $buyRequest->setQty($itemInfo['qty']);
             }
             $wishlist->addNewItem($productId, $buyRequest);
             $productIds[] = $productId;
             $cart->getQuote()->removeItem($itemId);
         }
     }
     if (count($productIds)) {
         $wishlist->save();
         $this->wishlistData->calculate();
     }
     return $this;
 }
 /**
  * Refresh stock index for specific stock items after successful order placement
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     // Reindex quote ids
     $quote = $observer->getEvent()->getQuote();
     $productIds = [];
     foreach ($quote->getAllItems() as $item) {
         $productIds[$item->getProductId()] = $item->getProductId();
         $children = $item->getChildrenItems();
         if ($children) {
             foreach ($children as $childItem) {
                 $productIds[$childItem->getProductId()] = $childItem->getProductId();
             }
         }
     }
     if ($productIds) {
         $this->stockIndexerProcessor->reindexList($productIds);
     }
     // Reindex previously remembered items
     $productIds = [];
     foreach ($this->itemsForReindex->getItems() as $item) {
         $item->save();
         $productIds[] = $item->getProductId();
     }
     if (!empty($productIds)) {
         $this->priceIndexer->reindexList($productIds);
     }
     $this->itemsForReindex->clear();
     // Clear list of remembered items - we don't need it anymore
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     try {
         if (!$this->_registry->registry('core_config_data_save_after_done')) {
             if ($groups = $observer->getEvent()->getConfigData()->getGroups()) {
                 if (isset($groups['catalog_sync']['fields']['catalog_values']['value'])) {
                     $configAfter = $groups['catalog_sync']['fields']['catalog_values']['value'];
                     $configBefore = $this->_registry->registry('core_config_data_save_before');
                     if ($configAfter != $configBefore) {
                         //reset catalog to re-import
                         $this->_connectorCatalogFactory->create()->reset();
                     }
                     $this->_registry->register('core_config_data_save_after_done', true);
                 }
             }
         }
         if (!$this->_registry->registry('core_config_data_save_after_done_status')) {
             if ($groups = $observer->getEvent()->getConfigData()->getGroups()) {
                 if (isset($groups['data_fields']['fields']['order_statuses']['value'])) {
                     $configAfter = $groups['data_fields']['fields']['order_statuses']['value'];
                     $configBefore = $this->_registry->registry('core_config_data_save_before_status');
                     if ($configAfter != $configBefore) {
                         //reset all contacts
                         $this->_connectorContactFactory->create()->resetAllContacts();
                     }
                     $this->_registry->register('core_config_data_save_after_done_status', true);
                 }
             }
         }
     } catch (\Exception $e) {
         $this->_helper->debug((string) $e, array());
     }
     return $this;
 }
 /**
  * If it's configured to capture on shipment - do this.
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $customer = $observer->getEvent()->getCustomer();
     $email = $customer->getEmail();
     $websiteId = $customer->getWebsiteId();
     $apiEnabled = $this->helper->isEnabled($websiteId);
     $customerSync = $this->helper->isCustomerSyncEnabled($websiteId);
     /*
      * Remove contact.
      */
     if ($apiEnabled && $customerSync) {
         try {
             //register in queue with importer
             $this->importerFactory->create()->registerQueue(\Dotdigitalgroup\Email\Model\Importer::IMPORT_TYPE_CONTACT, $email, \Dotdigitalgroup\Email\Model\Importer::MODE_CONTACT_DELETE, $websiteId);
             $contactModel = $this->contactFactory->create()->loadByCustomerEmail($email, $websiteId);
             if ($contactModel->getId()) {
                 //remove contact
                 $contactModel->delete();
             }
         } catch (\Exception $e) {
             $this->helper->debug((string) $e, []);
         }
     }
     return $this;
 }
Beispiel #7
0
 public function execute(Observer $observer)
 {
     if (!$this->_api->enabled()) {
         return;
     }
     try {
         /** @var $order Order */
         $order = $observer->getEvent()->getOrder();
         // Check if a payment is available for this order yet
         if ($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) {
             return;
         }
         // Check if case already exists for this order
         if ($this->_helper->doesCaseExist($order)) {
             return;
         }
         $orderData = $this->_helper->processOrderData($order);
         // Add order to database
         $case = $this->_helper->createNewCase($order);
         // Post case to signifyd service
         $result = $this->_helper->postCaseToSignifyd($orderData, $order);
         if ($order->canHold()) {
             $order->hold()->getResource()->save($order);
         }
         if ($result) {
             $case->setCode($result);
             $case->setMagentoStatus(CaseRetry::IN_REVIEW_STATUS)->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
             $case->getResource()->save($case);
         }
     } catch (\Exception $ex) {
         $this->_logger->error($ex->getMessage());
     }
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return \Magento\Quote\Model\Quote\Item
  */
 public function execute(\Magento\Framework\Event\Observer $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;
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $activationHelper = $this->_objectManager->get('LoginRadius\\Activation\\Model\\Helper\\Data');
     $customerRegistrationHelper = $this->_objectManager->get("LoginRadius" . "\\" . $activationHelper->getAuthDirectory() . "\\Model\\Helper\\Data");
     if ($customerRegistrationHelper->enableRaas() != '1') {
         return;
     }
     $events = $observer->getEvent();
     $customer = $events->getCustomerDataObject();
     $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#\$%^&*()_-=?";
     $birthDate = date("m-d-Y", strtotime($customer->getDob()));
     $newUserData = array('emailid' => $customer->getEmail(), 'firstname' => $customer->getFirstname(), 'lastname' => $customer->getLastname(), 'password' => substr(str_shuffle($chars), 0, 8), 'gender' => $this->getGenderValue($customer->getGender()), 'birthdate' => $birthDate);
     $userAPI = new \LoginRadiusSDK\CustomerRegistration\UserAPI($activationHelper->siteApiKey(), $activationHelper->siteApiSecret(), array('authentication' => true, 'output_format' => 'json'));
     $homeDomain = $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->getBaseUrl();
     if (!isset($_POST['customer']['entity_id'])) {
         try {
             $userCreatedata = $userAPI->create($newUserData);
             try {
                 $rsetPasswordUrl = 'https://api.loginradius.com/raas/client/password/forgot?apikey=' . $activationHelper->siteApiKey() . '&emailid=' . $customer->getEmail() . '&resetpasswordurl=' . $homeDomain . 'customer/account/login/';
                 $result = \LoginRadiusSDK\LoginRadius::apiClient($rsetPasswordUrl, FALSE, array('output_format' => 'json'));
             } catch (\LoginRadiusSDK\LoginRadiusException $e) {
                 $errorDescription = isset($e->getErrorResponse()->description) ? $e->getErrorResponse()->description : '';
                 $this->_messageManager->addError($errorDescription);
             }
             try {
                 $this->socialLinkingData($customer->getId(), $userCreatedata);
             } catch (\Exception $e) {
             }
         } catch (\LoginRadiusSDK\LoginRadiusException $e) {
         }
         return;
     }
 }
 /**
  * If it's configured to capture on shipment - do this
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $customer = $observer->getEvent()->getCustomer();
     $email = $customer->getEmail();
     $websiteId = $customer->getWebsiteId();
     $customerId = $customer->getEntityId();
     $isSubscribed = $customer->getIsSubscribed();
     try {
         // fix for a multiple hit of the observer
         $emailReg = $this->_registry->registry($email . '_customer_save');
         if ($emailReg) {
             return $this;
         }
         $this->_registry->register($email . '_customer_save', $email);
         $emailBefore = $this->_customerFactory->create()->load($customer->getId())->getEmail();
         $contactModel = $this->_contactFactory->create()->loadByCustomerEmail($emailBefore, $websiteId);
         //email change detection
         if ($email != $emailBefore) {
             $this->_helper->log('email change detected : ' . $email . ', after : ' . $emailBefore . ', website id : ' . $websiteId);
             $data = array('emailBefore' => $emailBefore, 'email' => $email, 'isSubscribed' => $isSubscribed);
             $this->_proccessor->registerQueue(\Dotdigitalgroup\Email\Model\Proccessor::IMPORT_TYPE_CONTACT_UPDATE, $data, \Dotdigitalgroup\Email\Model\Proccessor::MODE_CONTACT_EMAIL_UPDATE, $websiteId);
         } elseif (!$emailBefore) {
             //for new contacts update email
             $contactModel->setEmail($email);
         }
         $contactModel->setEmailImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED)->setCustomerId($customerId)->save();
     } catch (\Exception $e) {
         $this->_helper->debug((string) $e, array());
     }
     return $this;
 }
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     // get the product object
     $_product = $observer->getProduct();
     // pass the SKU to Processwire
     $this->updateWireProduct($_product, 'On Save');
 }
 /**
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(Observer $observer)
 {
     /** @var $customer \Magento\Customer\Api\Data\CustomerInterface */
     $customer = $observer->getEvent()->getCustomer();
     // Check if customer is valid (remove persistent cookie for invalid customer)
     if (!$customer || !$customer->getId() || !$this->_persistentSession->isRememberMeChecked()) {
         $this->_sessionFactory->create()->removePersistentCookie();
         return;
     }
     $persistentLifeTime = $this->_persistentData->getLifeTime();
     // Delete persistent session, if persistent could not be applied
     if ($this->_persistentData->isEnabled() && $persistentLifeTime <= 0) {
         // Remove current customer persistent session
         $this->_sessionFactory->create()->deleteByCustomerId($customer->getId());
         return;
     }
     /** @var $sessionModel \Magento\Persistent\Model\Session */
     $sessionModel = $this->_persistentSession->getSession();
     // Check if session is wrong or not exists, so create new session
     if (!$sessionModel->getId() || $sessionModel->getCustomerId() != $customer->getId()) {
         /** @var \Magento\Persistent\Model\Session $sessionModel */
         $sessionModel = $this->_sessionFactory->create();
         $sessionModel->setLoadExpired()->loadByCustomerId($customer->getId());
         if (!$sessionModel->getId()) {
             /** @var \Magento\Persistent\Model\Session $sessionModel */
             $sessionModel = $this->_sessionFactory->create();
             $sessionModel->setCustomerId($customer->getId())->save();
         }
         $this->_persistentSession->setSession($sessionModel);
     }
     // Set new cookie
     if ($sessionModel->getId()) {
         $sessionModel->setPersistentCookie($persistentLifeTime, $this->_customerSession->getCookiePath());
     }
 }
 /**
  * Apply catalog price rules to product in admin
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $product = $observer->getEvent()->getProduct();
     $storeId = $product->getStoreId();
     $date = $this->localeDate->scopeDate($storeId);
     $key = false;
     $ruleData = $this->coreRegistry->registry('rule_data');
     if ($ruleData) {
         $wId = $ruleData->getWebsiteId();
         $gId = $ruleData->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     } elseif ($product->getWebsiteId() !== null && $product->getCustomerGroupId() !== null) {
         $wId = $product->getWebsiteId();
         $gId = $product->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     }
     if ($key) {
         if (!$this->rulePricesStorage->hasRulePrice($key)) {
             $rulePrice = $this->resourceRuleFactory->create()->getRulePrice($date, $wId, $gId, $pId);
             $this->rulePricesStorage->setRulePrice($key, $rulePrice);
         }
         if ($this->rulePricesStorage->getRulePrice($key) !== false) {
             $finalPrice = min($product->getData('final_price'), $this->rulePricesStorage->getRulePrice($key));
             $product->setFinalPrice($finalPrice);
         }
     }
     return $this;
 }
 /**
  * Unlock customer on success login attempt.
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Customer\Model\Customer $customer */
     $customer = $observer->getEvent()->getData('model');
     $this->authentication->unlock($customer->getId());
     return $this;
 }
 /**
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     /** @var \Magento\Sales\Model\Order\Payment $orderPayment */
     $orderPayment = $observer->getEvent()->getPayment();
     $agreementCreated = false;
     if ($orderPayment->getBillingAgreementData()) {
         $order = $orderPayment->getOrder();
         /** @var \Magento\Paypal\Model\Billing\Agreement $agreement */
         $agreement = $this->agreementFactory->create()->importOrderPayment($orderPayment);
         if ($agreement->isValid()) {
             $message = __('Created billing agreement #%1.', $agreement->getReferenceId());
             $order->addRelatedObject($agreement);
             $agreement->addOrderRelation($order);
             $this->checkoutSession->setLastBillingAgreementReferenceId($agreement->getReferenceId());
             $agreementCreated = true;
         } else {
             $message = __('We can\'t create a billing agreement for this order.');
         }
         $comment = $order->addStatusHistoryComment($message);
         $order->addRelatedObject($comment);
     }
     if (!$agreementCreated) {
         $this->checkoutSession->unsLastBillingAgreementReferenceId();
     }
 }
 /**
  * Process shipping method and save
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if ($this->shipperDataHelper->getConfigValue('carriers/shipper/active')) {
         $request = $observer->getEvent()->getRequest();
         $shippingMethods = $request->getPost('shipping_method', '');
         if (!is_array($shippingMethods)) {
             return;
         }
         foreach ($shippingMethods as $addressId => $shippingMethod) {
             if (empty($shippingMethod)) {
                 return;
             }
             $quote = $observer->getEvent()->getQuote();
             $addresses = $quote->getAllShippingAddresses();
             $shippingAddress = false;
             foreach ($addresses as $address) {
                 if ($address->getId() == $addressId) {
                     $shippingAddress = $address;
                     break;
                 }
             }
             $this->carrierGroupHelper->saveCarrierGroupInformation($shippingAddress, $shippingMethod);
         }
     }
 }
 /**
  * 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 = $observer->getEvent()->getData('order');
     $this->authorizenetData->updateOrderEditIncrements($order);
     return $this;
 }
 /**
  * Update items stock status and low stock date.
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     $website = $observer->getEvent()->getWebsite();
     $this->resourceStock->updateSetOutOfStock($website);
     $this->resourceStock->updateSetInStock($website);
     $this->resourceStock->updateLowStockDate($website);
 }
 /**
  * Execute method.
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $order = $observer->getEvent()->getOrder();
     $email = $order->getCustomerEmail();
     $website = $this->storeManager->getWebsite($order->getWebsiteId());
     $storeName = $this->storeManager->getStore($order->getStoreId())->getName();
     //if api is not enabled
     if (!$this->helper->isEnabled($website)) {
         return $this;
     }
     //automation enrolment for order
     if ($order->getCustomerIsGuest()) {
         // guest to automation mapped
         $programType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER';
         $automationType = \Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_GUEST_ORDER;
     } else {
         // customer to automation mapped
         $programType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER';
         $automationType = \Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_ORDER;
     }
     $programId = $this->helper->getAutomationIdByType($programType, $order->getWebsiteId());
     //the program is not mapped
     if (!$programId) {
         return $this;
     }
     try {
         $this->automationFactory->create()->setEmail($email)->setAutomationType($automationType)->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)->setTypeId($order->getId())->setWebsiteId($website->getId())->setStoreName($storeName)->setProgramId($programId)->save();
     } catch (\Exception $e) {
         $this->helper->debug((string) $e, []);
     }
     return $this;
 }
 /**
  * Add stock information to product
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     $product = $observer->getEvent()->getProduct();
     if ($product instanceof \Magento\Catalog\Model\Product) {
         $this->stockHelper->assignStatusToProduct($product);
     }
 }
Beispiel #21
0
 /**
  * Set new customer group to all his quotes
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function dispatch(\Magento\Framework\Event\Observer $observer)
 {
     /** @var CustomerData $customerDataObject */
     $customerDataObject = $observer->getEvent()->getCustomerDataObject();
     /** @var CustomerData $origCustomerDataObject */
     $origCustomerDataObject = $observer->getEvent()->getOrigCustomerDataObject();
     if ($customerDataObject->getGroupId() !== $origCustomerDataObject->getGroupId()) {
         /**
          * It is needed to process customer's quotes for all websites
          * if customer accounts are shared between all of them
          */
         /** @var $websites \Magento\Store\Model\Website[] */
         $websites = $this->_config->isWebsiteScope() ? array($this->_storeManager->getWebsite($customerDataObject->getWebsiteId())) : $this->_storeManager->getWebsites();
         foreach ($websites as $website) {
             $quote = $this->_quoteFactory->create();
             $quote->setWebsite($website);
             $quote->loadByCustomer($customerDataObject->getId());
             if ($quote->getId()) {
                 $quote->setCustomerGroupId($customerDataObject->getGroupId());
                 $quote->collectTotals();
                 $quote->save();
             }
         }
     }
 }
 /**
  * If it's configured to capture on shipment - do this
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $object = $observer->getEvent()->getDataObject();
     $wishlist = $this->_wishlist->create()->load($object->getWishlistId());
     $emailWishlist = $this->_wishlistFactory->create();
     try {
         if ($object->getWishlistId()) {
             $itemCount = count($wishlist->getItemCollection());
             $item = $emailWishlist->getWishlist($object->getWishlistId());
             if ($item && $item->getId()) {
                 $preSaveItemCount = $item->getItemCount();
                 if ($itemCount != $item->getItemCount()) {
                     $item->setItemCount($itemCount);
                 }
                 if ($itemCount == 1 && $preSaveItemCount == 0) {
                     $item->setWishlistImported(null);
                 } elseif ($item->getWishlistImported()) {
                     $item->setWishlistModified(1);
                 }
                 $item->save();
             }
         }
     } catch (\Exception $e) {
         $this->_helper->debug((string) $e, array());
     }
     return $this;
 }
 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);
 }
 /**
  * Add price index data for catalog product collection
  * only for front end
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $collection = $observer->getEvent()->getCollection();
     /* @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */
     $collection->addPriceData();
     return $this;
 }
 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);
 }
 /**
  * @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;
                 }
             }
         }
     }
 }
 /**
  * Push additional actions to tracker before `trackPageView' is added
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return \Henhed\Piwik\Observer\BeforeTrackPageViewObserver
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $tracker = $observer->getEvent()->getTracker();
     /* @var $tracker \Henhed\Piwik\Model\Tracker */
     $this->_pushLinkTracking($tracker);
     return $this;
 }
 /**
  * Save order into registry to use it in the overloaded controller.
  *
  * @param EventObserver $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     /* @var $order \Magento\Sales\Model\Order */
     $order = $observer->getEvent()->getData('order');
     $this->_coreRegistry->register('hss_order', $order, true);
     return $this;
 }
 /**
  * Adds 'used_in_recommender' form field
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function addUsedInRecommender(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getEvent()->getForm();
     $fieldset = $form->getElement('advanced_fieldset');
     $fieldset->addField('used_in_recommender', 'select', ['name' => 'used_in_recommender', 'label' => __('Used in Recommender'), 'title' => __('Used in Recommender (Exported to the recommender system)'), 'note' => __('Exported to the recommender system'), 'values' => $this->_yesNo->toOptionArray()]);
 }
Beispiel #30
0
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->popupMessageManager->getPopups()) {
         $block = $observer->getLayout()->addBlock('Magento\\Framework\\View\\Element\\Template', 'swissup_popup_messages', 'before.body.end');
         $block->setTemplate('Swissup_Core::popup_messages.phtml')->setData('popup_messenger', $this->popupMessageManager);
     }
 }