/** * @return $this|void */ protected function _prepareLayout() { if (!$this->_moduleManager->isEnabled('Magento_Reports')) { return $this; } $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group'); $collection = $this->_collectionFactory->create()->calculateSales($isFilter); if ($this->getRequest()->getParam('store')) { $collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store')); } else { if ($this->getRequest()->getParam('website')) { $storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); $collection->addFieldToFilter('store_id', array('in' => $storeIds)); } else { if ($this->getRequest()->getParam('group')) { $storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); $collection->addFieldToFilter('store_id', array('in' => $storeIds)); } } } $collection->load(); $sales = $collection->getFirstItem(); $this->addTotal(__('Lifetime Sales'), $sales->getLifetime()); $this->addTotal(__('Average Orders'), $sales->getAverage()); }
/** * @return $this|void */ protected function _prepareLayout() { if (!$this->_moduleManager->isEnabled('Magento_Reports')) { return $this; } $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group'); $period = $this->getRequest()->getParam('period', '24h'); /* @var $collection \Magento\Reports\Model\Resource\Order\Collection */ $collection = $this->_collectionFactory->create()->addCreateAtPeriodFilter($period)->calculateTotals($isFilter); if ($this->getRequest()->getParam('store')) { $collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store')); } else { if ($this->getRequest()->getParam('website')) { $storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); $collection->addFieldToFilter('store_id', ['in' => $storeIds]); } else { if ($this->getRequest()->getParam('group')) { $storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); $collection->addFieldToFilter('store_id', ['in' => $storeIds]); } elseif (!$collection->isLive()) { $collection->addFieldToFilter('store_id', ['eq' => $this->_storeManager->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()]); } } } $collection->load(); $totals = $collection->getFirstItem(); $this->addTotal(__('Revenue'), $totals->getRevenue()); $this->addTotal(__('Tax'), $totals->getTax()); $this->addTotal(__('Shipping'), $totals->getShipping()); $this->addTotal(__('Quantity'), $totals->getQuantity() * 1, true); }
/** * @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; } } } } }
/** * Retrieve stock option array * * @return array */ public function getStockOption() { if ($this->moduleManager->isEnabled('Magento_CatalogInventory')) { return $this->stock->toOptionArray(); } return []; }
/** * @return $this */ protected function _prepareCollection() { if (!$this->_moduleManager->isEnabled('Magento_Reports')) { return $this; } $collection = $this->_collectionFactory->create()->addItemCountExpr()->joinCustomerName('customer')->orderByCreatedAt(); if ($this->getParam('store') || $this->getParam('website') || $this->getParam('group')) { if ($this->getParam('store')) { $collection->addAttributeToFilter('store_id', $this->getParam('store')); } else { if ($this->getParam('website')) { $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds(); $collection->addAttributeToFilter('store_id', array('in' => $storeIds)); } else { if ($this->getParam('group')) { $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds(); $collection->addAttributeToFilter('store_id', array('in' => $storeIds)); } } } $collection->addRevenueToSelect(); } else { $collection->addRevenueToSelect(true); } $this->setCollection($collection); return parent::_prepareCollection(); }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) { $this->checkoutSession->clearStorage(); } return $result; }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) { $this->eventManager->dispatch('depersonalize_clear_session'); session_write_close(); $this->messageSession->clearStorage(); } return $result; }
/** * Get Magefan Modules Info * * @return $this */ protected function getMagefanModules() { $modules = array(); foreach ($this->_moduleList->getAll() as $moduleName => $module) { if (strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName)) { $modules[$moduleName] = $module; } } return $modules; }
/** * Check if we can show this block. * According to @see \Magento\LayeredNavigationStaging\Block\Navigation::canShowBlock * We should not show the block if staging is enabled and if we are currently previewing the results. * * @return bool */ public function canShowBlock() { if ($this->moduleManager->isEnabled('Magento_Staging')) { try { $versionManager = $this->objectManager->get('\\Magento\\Staging\\Model\\VersionManager'); return parent::canShowBlock() && !$versionManager->isPreviewVersion(); } catch (\Exception $exception) { return parent::canShowBlock(); } } return parent::canShowBlock(); }
/** * Return array of customer groups * * @return array */ public function toOptionArray() { if (!$this->moduleManager->isEnabled('Magento_Customer')) { return []; } $customerGroups = [['label' => __('ALL GROUPS'), 'value' => GroupInterface::CUST_GROUP_ALL]]; /** @var GroupInterface[] $groups */ $groups = $this->groupRepository->getList($this->searchCriteriaBuilder->create()); foreach ($groups->getItems() as $group) { $customerGroups[] = ['label' => $group->getCode(), 'value' => $group->getId()]; } return $customerGroups; }
/** * @return Grid */ protected function _prepareCollection() { $productId = $this->getRequest()->getParam('id'); $websiteId = 0; if ($store = $this->getRequest()->getParam('store')) { $websiteId = $this->_storeManager->getStore($store)->getWebsiteId(); } if ($this->moduleManager->isEnabled('Magento_ProductAlert')) { $collection = $this->_priceFactory->create()->getCustomerCollection()->join($productId, $websiteId); $this->setCollection($collection); } return parent::_prepareCollection(); }
/** * @param \Magento\Framework\App\ActionInterface $subject * @param callable $proceed * @param \Magento\Framework\App\RequestInterface $request * @return mixed * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundDispatch(\Magento\Framework\App\ActionInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request) { if (!$this->customerSession->isLoggedIn() || !$this->moduleManager->isEnabled('Magento_PageCache') || !$this->cacheConfig->isEnabled() || !$this->taxHelper->isCatalogPriceDisplayAffectedByTax()) { return $proceed($request); } $defaultBillingAddress = $this->customerSession->getDefaultTaxBillingAddress(); $defaultShippingAddress = $this->customerSession->getDefaultTaxShippingAddress(); $customerTaxClassId = $this->customerSession->getCustomerTaxClassId(); if (!empty($defaultBillingAddress) || !empty($defaultShippingAddress)) { $taxRates = $this->taxCalculation->getTaxRates($defaultBillingAddress, $defaultShippingAddress, $customerTaxClassId); $this->httpContext->setValue('tax_rates', $taxRates, 0); } return $proceed($request); }
/** * @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 $customerAddress Address */ $address = $observer->getCustomerAddress(); // Check if the address is either the default billing, shipping, or both if ($this->isDefaultBilling($address)) { $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegionId() : null, 'postcode' => $address->getPostcode()]); } if ($this->isDefaultShipping($address)) { $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegionId() : null, 'postcode' => $address->getPostcode()]); } } }
/** * List of available search indexes * * @return DataObject[] */ public function getAvailableIndexes() { $indexes = []; if ($this->moduleManager->isEnabled('Mirasvit_Search')) { $indexCollectionFactory = $this->objectManager->create('\\Mirasvit\\Search\\Model\\ResourceModel\\Index\\CollectionFactory'); $collection = $indexCollectionFactory->create()->addFieldToFilter('is_active', true); foreach ($collection as $index) { $indexes[] = $index; } } else { $indexes[] = new DataObject(['title' => __('Products')->__toString(), 'code' => 'catalogsearch_fulltext']); } $indexes[] = new DataObject(['title' => __('Popular suggestions')->__toString(), 'code' => 'magento_search_query']); return $indexes; }
/** * @return $this */ protected function _prepareData() { $product = $this->_coreRegistry->registry('product'); /* @var $product \Magento\Catalog\Model\Product */ $this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect('required_options')->setPositionOrder()->addStoreFilter(); if ($this->moduleManager->isEnabled('Magento_Checkout')) { $this->_addProductAttributesAndPrices($this->_itemCollection); } $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds()); $this->_itemCollection->load(); foreach ($this->_itemCollection as $product) { $product->setDoNotUseCategoryId(true); } return $this; }
/** * Premare block data * @return $this */ protected function _prepareCollection() { $post = $this->_coreRegistry->registry('current_blog_post'); $this->_itemCollection = $this->_productCollectionFactory->create()->addAttributeToSelect('required_options')->addStoreFilter()->addAttributeToFilter('entity_id', array('in' => $post->getRelatedProductIds() ?: array(0))); if ($this->_moduleManager->isEnabled('Magento_Checkout')) { $this->_addProductAttributesAndPrices($this->_itemCollection); } $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds()); $this->_itemCollection->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_products/number_of_products', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); $this->_itemCollection->load(); foreach ($this->_itemCollection as $product) { $product->setDoNotUseCategoryId(true); } return $this; }
/** * Check whether wysiwyg enabled or not * * @return bool * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ public function getIsWysiwygEnabled() { if ($this->_moduleManager->isEnabled('Magento_Cms')) { return (bool) ($this->_wysiwygConfig->isEnabled() && $this->getEntityAttribute()->getIsWysiwygEnabled()); } return false; }
/** * Premare block data * @return $this */ protected function _prepareCollection() { $post = $this->getPost(); $this->_itemCollection = $post->getRelatedProducts()->addAttributeToSelect('required_options'); if ($this->_moduleManager->isEnabled('Magento_Checkout')) { $this->_addProductAttributesAndPrices($this->_itemCollection); } $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds()); $this->_itemCollection->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_products/number_of_products', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); $this->_itemCollection->getSelect()->order('rl.position', 'ASC'); $this->_itemCollection->load(); foreach ($this->_itemCollection as $product) { $product->setDoNotUseCategoryId(true); } return $this; }
/** * @param \Magento\Framework\App\ActionInterface $subject * @param callable $proceed * @param \Magento\Framework\App\RequestInterface $request * @return mixed * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function aroundExecute( \Magento\Framework\App\ActionInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { if (!$this->weeeHelper->isEnabled() || !$this->customerSession->isLoggedIn() || !$this->moduleManager->isEnabled('Magento_PageCache') || !$this->cacheConfig->isEnabled()) { return $proceed($request); } $basedOn = $this->taxHelper->getTaxBasedOn(); if ($basedOn != 'shipping' && $basedOn != 'billing') { return $proceed($request); } $weeeTaxRegion = $this->getWeeeTaxRegion($basedOn); $websiteId = $this->storeManager->getStore()->getWebsiteId(); $countryId = $weeeTaxRegion['countryId']; $regionId = $weeeTaxRegion['regionId']; if (!$countryId && !$regionId) { // country and region does not exist return $proceed($request); } else if ($countryId && !$regionId) { // country exist and region does not exist $regionId = 0; $exist = $this->weeeTax->isWeeeInLocation( $countryId, $regionId, $websiteId ); } else { // country and region exist $exist = $this->weeeTax->isWeeeInLocation( $countryId, $regionId, $websiteId ); if (!$exist) { // just check the country for weee $regionId = 0; $exist = $this->weeeTax->isWeeeInLocation( $countryId, $regionId, $websiteId ); } } if ($exist) { $this->httpContext->setValue( 'weee_tax_region', ['countryId' => $countryId, 'regionId' => $regionId], 0 ); } return $proceed($request); }
/** * @return $this * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _prepareColumns() { $this->addColumn('entity_id', ['header' => __('ID'), 'type' => 'number', 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']); $this->addColumn('name', ['header' => __('Name'), 'index' => 'name', 'class' => 'xxx']); $store = $this->_getStore(); if ($store->getId()) { $this->addColumn('custom_name', ['header' => __('Name in %1', $store->getName()), 'index' => 'custom_name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']); } $this->addColumn('type', ['header' => __('Type'), 'index' => 'type_id', 'type' => 'options', 'options' => $this->_type->getOptionArray()]); $sets = $this->_setsFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash(); $this->addColumn('set_name', ['header' => __('Attribute Set'), 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, 'header_css_class' => 'col-attr-name', 'column_css_class' => 'col-attr-name']); $this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku']); $store = $this->_getStore(); $this->addColumn('price', ['header' => __('Price'), 'type' => 'price', 'currency_code' => $store->getBaseCurrency()->getCode(), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price']); if ($this->moduleManager->isEnabled('Magento_CatalogInventory')) { $this->addColumn('qty', ['header' => __('Quantity'), 'type' => 'number', 'index' => 'qty']); } $this->addColumn('visibility', ['header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility']); $this->addColumn('status', ['header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray()]); if (!$this->_storeManager->isSingleStoreMode()) { $this->addColumn('websites', ['header' => __('Websites'), 'sortable' => false, 'index' => 'websites', 'type' => 'options', 'options' => $this->_websiteFactory->create()->getCollection()->toOptionHash(), 'header_css_class' => 'col-websites', 'column_css_class' => 'col-websites']); } $this->addColumn('edit', ['header' => __('Edit'), 'type' => 'action', 'getter' => 'getId', 'actions' => [['caption' => __('Edit'), 'url' => ['base' => '*/*/edit', 'params' => ['store' => $this->getRequest()->getParam('store')]], 'field' => 'id']], 'filter' => false, 'sortable' => false, 'index' => 'stores', 'header_css_class' => 'col-action', 'column_css_class' => 'col-action']); $block = $this->getLayout()->getBlock('grid.bottom.links'); if ($block) { $this->setChild('grid.bottom.links', $block); } return parent::_prepareColumns(); }
/** * Check is module exists and enabled in global config. * * @param string $moduleName the full module name, example Magento_Core * @return boolean * @deprecated use \Magento\Framework\Module\Manager::isEnabled() */ public function isModuleEnabled($moduleName = null) { if ($moduleName === null) { $moduleName = $this->_getModuleName(); } return $this->_moduleManager->isEnabled($moduleName); }
/** * @param \Magento\Catalog\Model\Resource\Product\Collection $collection * @throws \Magento\Framework\Exception\LocalizedException */ protected function _joinInventoryFields(\Magento\Catalog\Model\Resource\Product\Collection $collection) { if (!empty($this->_inventoryFields) && $this->moduleManager->isEnabled('Magento_CatalogInventory')) { foreach ($this->_inventoryFields as $field) { $collection->joinField($field, 'cataloginventory_stock_item', $field, 'product_id=entity_id', '{{table}}.stock_id=1', 'left'); } } }
/** * Returns current customer according to session and context * * @return \Magento\Customer\Service\V1\Data\Customer */ public function getCustomer() { if ($this->moduleManager->isEnabled('Magento_PageCache') && !$this->request->isAjax() && $this->view->isLayoutLoaded() && $this->layout->isCacheable()) { return $this->getDepersonalizedCustomer(); } else { return $this->getCustomerFromService(); } }
/** * {@inheritdoc} */ protected function _prepareCollection() { if (!$this->_moduleManager->isEnabled('Magento_Sales')) { return $this; } if ($this->getParam('website')) { $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds(); $storeId = array_pop($storeIds); } elseif ($this->getParam('group')) { $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds(); $storeId = array_pop($storeIds); } else { $storeId = (int) $this->getParam('store'); } $collection = $this->_collectionFactory->create()->setModel('Magento\\Catalog\\Model\\Product')->addStoreFilter($storeId); $this->setCollection($collection); return parent::_prepareCollection(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { if ($this->moduleManager->isEnabled('Magento_GoogleBase')) { $typesInsert = $setup->getConnection()->select()->from($setup->getTable('googlebase_types'), ['type_id', 'attribute_set_id', 'target_country', 'category' => new \Zend_Db_Expr('NULL')])->insertFromSelect($setup->getTable('googleshopping_types')); $itemsInsert = $setup->getConnection()->select()->from($setup->getTable('googlebase_items'), ['item_id', 'type_id', 'product_id', 'gbase_item_id', 'store_id', 'published', 'expires'])->insertFromSelect($setup->getTable('googleshopping_items')); $attributes = ''; foreach ($this->configFactory->create()->getAttributes() as $destAttribtues) { $keys = array_keys($destAttribtues); foreach ($keys as $code) { $attributes .= "'{$code}',"; } } $attributes = rtrim($attributes, ','); $attributesInsert = $setup->getConnection()->select()->from($setup->getTable('googlebase_attributes'), ['id', 'attribute_id', 'gbase_attribute' => new \Zend_Db_Expr("IF(gbase_attribute IN ({$attributes}), gbase_attribute, '')"), 'type_id'])->insertFromSelect($setup->getTable('googleshopping_attributes')); $setup->run($typesInsert); $setup->run($attributesInsert); $setup->run($itemsInsert); } }
/** * @return $this */ protected function _prepareData() { $product = $this->_coreRegistry->registry('product'); /* @var $product \Magento\Catalog\Model\Product */ $this->_itemCollection = $product->getUpSellProductCollection()->setPositionOrder()->addStoreFilter(); if ($this->moduleManager->isEnabled('Magento_Checkout')) { $this->_addProductAttributesAndPrices($this->_itemCollection); } $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds()); $this->_itemCollection->load(); /** * Updating collection with desired items */ $this->_eventManager->dispatch('catalog_product_upsell', ['product' => $product, 'collection' => $this->_itemCollection, 'limit' => null]); foreach ($this->_itemCollection as $product) { $product->setDoNotUseCategoryId(true); } return $this; }
/** * Get the crossell items for the basket page * * @return array */ public function getItems() { if (!$this->_config->isEnabled()) { return parent::getItems(); } $personalisedIds = $this->_crosssell->getProductCollection(); if (!$personalisedIds) { return parent::getItems(); } $collection = $this->_crosssell->getPersonalisedProductCollection($personalisedIds); if ($this->_moduleManager->isEnabled('Magento_Checkout')) { $this->_addProductAttributesAndPrices($collection); } $items = []; foreach ($collection as $item) { $items[] = $item; } return $items; }
/** * Rewrite parent getAllItems method to use PredictionIO results when available * Rewrites the target rules for Enterprise edition * * @return array */ public function getAllItems() { if (!$this->_config->isEnabled() || !$this->_config->getItem(Config::SIMILARITY_REPLACE_RULES)) { return parent::getAllItems(); } $product = $this->_coreRegistry->registry('product'); $categoryIds = $this->_upsell->getCategoryIds($product); $personalisedIds = $this->_upsell->getProductCollection([$product->getId()], $categoryIds); if (!$personalisedIds) { return parent::getAllItems(); } $collection = $this->_upsell->getPersonalisedProductCollection($personalisedIds); if ($this->_moduleManager->isEnabled('Magento_Checkout')) { $this->_addProductAttributesAndPrices($collection); } $items = []; foreach ($collection as $product) { $product->setDoNotUseCategoryId(true); $items[] = $product; } return $items; }
/** * @return $this */ protected function _prepareCollection() { if (!$this->_moduleManager->isEnabled('Magento_CatalogSearch')) { return parent::_prepareCollection(); } $this->_collection = $this->_queriesFactory->create(); $this->_collection->setRecentQueryFilter(); if ($this->getRequest()->getParam('store')) { $this->_collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store')); } else { if ($this->getRequest()->getParam('website')) { $storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds)); } else { if ($this->getRequest()->getParam('group')) { $storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds)); } } } $this->setCollection($this->_collection); return parent::_prepareCollection(); }
/** * Address after save event handler * * @param \Magento\Framework\Event\Observer $observer * @return void * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function afterAddressSave($observer) { if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->weeeHelper->isEnabled()) { /** @var $customerAddress Address */ $address = $observer->getCustomerAddress(); // Check if the address is either the default billing, shipping, or both if ($address->getIsPrimaryBilling() || $address->getIsDefaultBilling()) { $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegionId() : null, 'postcode' => $address->getPostcode()]); } if ($address->getIsPrimaryShipping() || $address->getIsDefaultShipping()) { $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegionId() : null, 'postcode' => $address->getPostcode()]); } } }