/** * Check whether asset minification is on for specified content type * * @param string $contentType * @return bool */ public function isEnabled($contentType) { if (!isset($this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType])) { $this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType] = $this->appState->getMode() != State::MODE_DEVELOPER && (bool) $this->scopeConfig->isSetFlag(sprintf(self::XML_PATH_MINIFICATION_ENABLED, $contentType), $this->scope); } return $this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType]; }
/** * @return \Magento\Framework\Controller\Result\Forward|\Magento\Framework\View\Result\Page */ public function execute() { $articleId = (int) $this->getRequest()->getParam('id'); $article = $this->articleFactory->create(); $article->load($articleId); if (!$article->isActive()) { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } $this->coreRegistry->register('current_article', $article); $resultPage = $this->resultPageFactory->create(); $title = $article->getMetaTitle() ?: $article->getName(); $resultPage->getConfig()->getTitle()->set($title); $resultPage->getConfig()->setDescription($article->getMetaDescription()); $resultPage->getConfig()->setKeywords($article->getMetaKeywords()); if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) { /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbsBlock */ $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs'); if ($breadcrumbsBlock) { $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'link' => $this->_url->getUrl('')]); $breadcrumbsBlock->addCrumb('articles', ['label' => __('Articles'), 'link' => $this->urlModel->getListUrl()]); $breadcrumbsBlock->addCrumb('article-' . $article->getId(), ['label' => $article->getName()]); } } return $resultPage; }
/** * Dispatch request * * @param RequestInterface $request * @return \Magento\Framework\App\ResponseInterface * @throws \Magento\Framework\Exception\NotFoundException */ public function dispatch(RequestInterface $request) { if (!$this->scopeConfig->isSetFlag(self::XML_PATH_ENABLED, ScopeInterface::SCOPE_STORE)) { throw new NotFoundException(__('Page not found.')); } return parent::dispatch($request); }
/** * Generate sitemaps * * @return void * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function scheduledGenerateSitemaps() { $errors = []; // check if scheduled generation enabled if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_GENERATION_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) { return; } $collection = $this->_collectionFactory->create(); /* @var $collection \Magento\Sitemap\Model\ResourceModel\Sitemap\Collection */ foreach ($collection as $sitemap) { /* @var $sitemap \Magento\Sitemap\Model\Sitemap */ try { $sitemap->generateXml(); } catch (\Exception $e) { $errors[] = $e->getMessage(); } } if ($errors && $this->_scopeConfig->getValue(self::XML_PATH_ERROR_RECIPIENT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) { $translate = $this->_translateModel->getTranslateInline(); $this->_translateModel->setTranslateInline(false); $this->_transportBuilder->setTemplateIdentifier($this->_scopeConfig->getValue(self::XML_PATH_ERROR_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE))->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['warnings' => join("\n", $errors)])->setFrom($this->_scopeConfig->getValue(self::XML_PATH_ERROR_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE))->addTo($this->_scopeConfig->getValue(self::XML_PATH_ERROR_RECIPIENT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); $this->inlineTranslation->resume(); } }
/** * Create Backup * * @return $this */ public function execute() { if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) { return $this; } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { $this->maintenanceMode->set(true); } $type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE); $this->_errors = []; try { $backupManager = $this->_backupFactory->create($type)->setBackupExtension($this->_backupData->getExtensionByType($type))->setTime(time())->setBackupsDir($this->_backupData->getBackupsDir()); $this->_coreRegistry->register('backup_manager', $backupManager); if ($type != \Magento\Framework\Backup\Factory::TYPE_DB) { $backupManager->setRootDir($this->_filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath())->addIgnorePaths($this->_backupData->getBackupIgnorePaths()); } $backupManager->create(); $message = $this->_backupData->getCreateSuccessMessageByType($type); $this->_logger->info($message); } catch (\Exception $e) { $this->_errors[] = $e->getMessage(); $this->_errors[] = $e->getTrace(); $this->_logger->info($e->getMessage()); $this->_logger->critical($e); } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { $this->maintenanceMode->set(false); } return $this; }
/** * Set current attribute to entry (for specified product) * * @param \Magento\Catalog\Model\Product $product * @param \Magento\Framework\Gdata\Gshopping\Entry $entry * @return \Magento\Framework\Gdata\Gshopping\Entry */ public function convertAttribute($product, $entry) { $url = $product->getProductUrl(false); if ($url) { $isStoreInUrl = $this->_scopeConfig->isSetFlag(\Magento\Store\Model\Store::XML_PATH_STORE_IN_URL, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); if (!$isStoreInUrl) { $urlInfo = parse_url($url); $store = $product->getStore()->getCode(); if (isset($urlInfo['query']) && $urlInfo['query'] != '') { $url .= '&___store=' . $store; } else { $url .= '?___store=' . $store; } } $links = $entry->getLink(); if (!is_array($links)) { $links = []; } $link = $entry->getService()->newLink(); $link->setHref($url); $link->setRel('alternate'); $link->setType('text/html'); if ($product->getName()) { $link->setTitle($product->getName()); } $links[0] = $link; $entry->setLink($links); } return $entry; }
/** * Get list of required Agreement Ids * * @return int[] */ public function getRequiredAgreementIds() { if (!$this->scopeConfig->isSetFlag(self::PATH_ENABLED, ScopeInterface::SCOPE_STORE)) { return []; } else { return $this->agreementCollectionFactory->create()->addStoreFilter($this->storeManager->getStore()->getId())->addFieldToFilter('is_active', 1)->getAllIds(); } }
/** * {@inheritdoc} */ public function getConfig() { $isAgreementsEnabled = $this->scopeConfiguration->isSetFlag(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE); if ($isAgreementsEnabled && count($this->checkoutAgreementsRepository->getList()) > 0) { return ['checkoutAgreementsEnabled' => true]; } return []; }
/** * {@inheritdoc} */ public function getConfig() { if ($this->scopeConfiguration->isSetFlag(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE)) { return ['checkoutAgreementsEnabled' => true]; } else { return []; } }
/** * @param \Magento\Customer\Api\Data\CustomerInterface $customer * @param string $redirectUrl * * @return $this */ public function sendEmailConfirmation(\Magento\Customer\Api\Data\CustomerInterface $customer, $redirectUrl) { $storeId = $this->getWebsiteStoreId($customer); if ($this->scopeConfig->isSetFlag(\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_DISABLE_CUSTOMER_SUCCESS, 'store', $storeId)) { return $this; } else { parent::sendEmailConfirmation($customer, $redirectUrl); } }
/** * @param array $data * @return object */ public function create(array $data = []) { if ($this->scopeConfig->isSetFlag(Payupl::XML_PATH_CLASSIC_API, 'store')) { $class = Client\Classic::class; } else { $class = Client\Rest::class; } return $this->objectManager->create($class, []); }
/** * Build index query * * @param RequestInterface $request * @return Select */ public function build(RequestInterface $request) { $select = $this->getSelect()->from(['search_index' => $this->resource->getTableName($request->getIndex())], ['entity_id' => 'search_index.product_id'])->joinLeft(['category_index' => $this->resource->getTableName('catalog_category_product_index')], 'search_index.product_id = category_index.product_id' . ' AND search_index.store_id = category_index.store_id', []); $isShowOutOfStock = $this->config->isSetFlag('cataloginventory/options/show_out_of_stock', ScopeInterface::SCOPE_STORE); if ($isShowOutOfStock === false) { $select->joinLeft(['stock_index' => $this->resource->getTableName('cataloginventory_stock_status')], 'search_index.product_id = stock_index.product_id' . $this->getReadConnection()->quoteInto(' AND stock_index.website_id = ?', $this->storeManager->getWebsite()->getId()), [])->where('stock_index.stock_status = ?', 1); } return $select; }
/** * Returns agreements config * * @return array */ protected function getAgreementsConfig() { $agreementConfiguration = []; $isAgreementsEnabled = $this->scopeConfiguration->isSetFlag(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE); $agreementsList = $this->checkoutAgreementsRepository->getList(); $agreementConfiguration['isEnabled'] = (bool) ($isAgreementsEnabled && count($agreementsList) > 0); foreach ($agreementsList as $agreement) { $agreementConfiguration['agreements'][] = ['content' => $agreement->getIsHtml() ? $agreement->getContent() : nl2br($this->escaper->escapeHtml($agreement->getContent())), 'checkboxText' => $agreement->getCheckboxText(), 'mode' => $agreement->getMode(), 'agreementId' => $agreement->getAgreementId()]; } return $agreementConfiguration; }
/** * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(\Magento\Framework\Event\Observer $observer) { /** @var Category $category */ $category = $observer->getEvent()->getCategory(); if ($category->dataHasChangedFor('parent_id')) { $saveRewritesHistory = $this->scopeConfig->isSetFlag(UrlKeyRenderer::XML_PATH_SEO_SAVE_HISTORY, ScopeInterface::SCOPE_STORE, $category->getStoreId()); $category->setData('save_rewrites_history', $saveRewritesHistory); $urlRewrites = array_merge($this->categoryUrlRewriteGenerator->generate($category), $this->urlRewriteHandler->generateProductUrlRewrites($category)); $this->urlRewriteHandler->deleteCategoryRewritesForChildren($category); $this->urlPersist->replace($urlRewrites); } }
/** * Get list of required Agreement Ids * * @return int[] */ public function getRequiredAgreementIds() { $agreementIds = []; if ($this->scopeConfig->isSetFlag(self::PATH_ENABLED, ScopeInterface::SCOPE_STORE)) { $agreementCollection = $this->agreementCollectionFactory->create(); $agreementCollection->addStoreFilter($this->storeManager->getStore()->getId()); $agreementCollection->addFieldToFilter('is_active', 1); $agreementCollection->addFieldToFilter('mode', AgreementModeOptions::MODE_MANUAL); $agreementIds = $agreementCollection->getAllIds(); } return $agreementIds; }
/** * Page block html topmenu gethtml before * * @param \Magento\Framework\Event\Observer $observer * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute(\Magento\Framework\Event\Observer $observer) { if (!$this->_scopeConfig->isSetFlag(static::XML_PATH_TOP_MENU_SHOW_ITEM, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) { return; } /** @var \Magento\Framework\Data\Tree\Node $menu */ $menu = $observer->getMenu(); $block = $observer->getBlock(); $tree = $menu->getTree(); $data = ['name' => $this->_scopeConfig->getValue(static::XML_PATH_TOP_MENU_ITEM_TEXT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'id' => 'magefan-blog', 'url' => $this->_url->getBaseUrl(), 'is_active' => $block->getRequest()->getModuleName() == 'blog']; $node = new Node($data, 'id', $tree, $menu); $menu->addChild($node); }
/** * Check is link shareable or not * * @param \Magento\Downloadable\Model\Link|Item $link * @return bool */ public function getIsShareable($link) { $shareable = false; switch ($link->getIsShareable()) { case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_YES: case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_NO: $shareable = (bool) $link->getIsShareable(); break; case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_CONFIG: $shareable = (bool) $this->_scopeConfig->isSetFlag(\Magento\Downloadable\Model\Link::XML_PATH_CONFIG_IS_SHAREABLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); } return $shareable; }
/** * Build index query * * @param RequestInterface $request * @return Select */ public function build(RequestInterface $request) { $searchIndexTable = $this->scopeResolver->resolve($request->getIndex(), $request->getDimensions()); $select = $this->resource->getConnection()->select()->from(['search_index' => $searchIndexTable], ['entity_id' => 'entity_id'])->joinLeft(['cea' => $this->resource->getTableName('catalog_eav_attribute')], 'search_index.attribute_id = cea.attribute_id', []); $select = $this->tableMapper->addTables($select, $request); $select = $this->processDimensions($request, $select); $isShowOutOfStock = $this->config->isSetFlag('cataloginventory/options/show_out_of_stock', ScopeInterface::SCOPE_STORE); if ($isShowOutOfStock === false) { $select->joinLeft(['stock_index' => $this->resource->getTableName('cataloginventory_stock_status')], 'search_index.entity_id = stock_index.product_id' . $this->resource->getConnection()->quoteInto(' AND stock_index.website_id = ?', $this->storeManager->getWebsite()->getId()), []); $select->where('stock_index.stock_status = ?', 1); } return $select; }
/** * Perform customer authentication and wishlist feature state checks * * @param \Magento\Framework\App\ActionInterface $subject * @param RequestInterface $request * @return void * @throws \Magento\Framework\Exception\NotFoundException */ public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request) { if ($this->authenticationState->isEnabled() && !$this->customerSession->authenticate($subject)) { $subject->getActionFlag()->set('', 'no-dispatch', true); if (!$this->customerSession->getBeforeWishlistUrl()) { $this->customerSession->setBeforeWishlistUrl($this->redirector->getRefererUrl()); } $this->customerSession->setBeforeWishlistRequest($request->getParams()); } if (!$this->config->isSetFlag('wishlist/general/active')) { throw new NotFoundException(__('Page not found.')); } }
/** * Retrieve parameters of customer login url * * @return array */ public function getLoginUrlParams() { $params = []; $referer = $this->request->getParam(self::REFERER_QUERY_PARAM_NAME); if (!$referer && !$this->scopeConfig->isSetFlag(self::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD, ScopeInterface::SCOPE_STORE) && !$this->customerSession->getNoReferer()) { $referer = $this->urlBuilder->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]); $referer = $this->urlEncoder->encode($referer); } if ($referer) { $params = [self::REFERER_QUERY_PARAM_NAME => $referer]; } return $params; }
/** * Get error message which can be displayed to website user * * @return string */ public function getUserMessage($error = null) { if (!empty($error)) { if ($this->_scopeConfig->isSetFlag('payment/mercadopago/debug_mode', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) { return $error['description']; } else { $code = $error['code']; if (isset($this->_messagesMap[$code])) { return __($this->_messagesMap[$code]); } } } return __(self::GENERIC_USER_MESSAGE); }
/** * Retrieve active system carriers * * @param mixed $store * @return array */ public function getActiveCarriers($store = null) { $carriers = array(); $config = $this->_scopeConfig->getValue('carriers', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store); foreach (array_keys($config) as $carrierCode) { if ($this->_scopeConfig->isSetFlag('carriers/' . $carrierCode . '/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store)) { $carrierModel = $this->_carrierFactory->create($carrierCode, $store); if ($carrierModel) { $carriers[$carrierCode] = $carrierModel; } } } return $carriers; }
/** * Adding URL rewrite checkbox to meta * * @param array $meta * @return array */ protected function addUrlRewriteCheckbox(array $meta) { $urlPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY); if ($urlPath) { $containerPath = $this->arrayManager->slicePath($urlPath, 0, -2); $urlKey = $this->locator->getProduct()->getData('url_key'); $saveRewritesHistory = $this->scopeConfig->isSetFlag(self::XML_PATH_SEO_SAVE_HISTORY, ScopeInterface::SCOPE_STORE, $this->locator->getProduct()->getStoreId()); $meta = $this->arrayManager->merge($containerPath, $meta, ['arguments' => ['data' => ['config' => ['component' => 'Magento_Ui/js/form/components/group']]]]); $checkbox['arguments']['data']['config'] = ['componentType' => Field::NAME, 'formElement' => Checkbox::NAME, 'dataType' => Text::NAME, 'component' => 'Magento_CatalogUrlRewrite/js/components/url-key-handle-changes', 'valueMap' => ['false' => '', 'true' => $urlKey], 'imports' => ['handleChanges' => '${ $.provider }:data.product.' . ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY], 'description' => __('Create Permanent Redirect for old URL'), 'dataScope' => 'url_key_create_redirect', 'value' => $saveRewritesHistory ? $urlKey : '', 'checked' => $saveRewritesHistory]; $meta = $this->arrayManager->merge($urlPath . '/arguments/data/config', $meta, ['valueUpdate' => 'keyup']); $meta = $this->arrayManager->merge($containerPath . '/children', $meta, ['url_key_create_redirect' => $checkbox]); $meta = $this->arrayManager->merge($containerPath . '/arguments/data/config', $meta, ['breakLine' => true]); } return $meta; }
/** * Create Backup * * @return \Magento\Log\Model\Cron */ public function scheduledBackup() { if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) { return $this; } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { $this->maintenanceMode->turnOn(); } $type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE); $this->_errors = array(); try { $backupManager = $this->_backupFactory->create($type)->setBackupExtension($this->_backupData->getExtensionByType($type))->setTime(time())->setBackupsDir($this->_backupData->getBackupsDir()); $this->_coreRegistry->register('backup_manager', $backupManager); if ($type != \Magento\Framework\Backup\Factory::TYPE_DB) { $backupManager->setRootDir($this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR))->addIgnorePaths($this->_backupData->getBackupIgnorePaths()); } $backupManager->create(); $message = $this->_backupData->getCreateSuccessMessageByType($type); $this->_logger->log($message); } catch (\Exception $e) { $this->_errors[] = $e->getMessage(); $this->_errors[] = $e->getTrace(); $this->_logger->log($e->getMessage(), \Zend_Log::ERR); $this->_logger->logException($e); } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { $this->maintenanceMode->turnOff(); } return $this; }
/** * {@inheritdoc} * * @return \Magento\CheckoutAgreements\Api\Data\AgreementInterface[] Array of checkout agreement data objects. */ public function getList() { if (!$this->scopeConfig->isSetFlag('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE)) { return []; } $storeId = $this->storeManager->getStore()->getId(); /** @var $agreementCollection AgreementCollection */ $agreementCollection = $this->collectionFactory->create(); $agreementCollection->addStoreFilter($storeId); $agreementCollection->addFieldToFilter('is_active', 1); $agreementDataObjects = []; foreach ($agreementCollection as $agreement) { $agreementDataObjects[] = $agreement; } return $agreementDataObjects; }
/** * Iterate through website configurations and collect all SFTP configurations * Filter config values if necessary * * @param bool $automaticMode Whether to skip settings with disabled Automatic Fetching or not * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ public function getSftpCredentials($automaticMode = false) { $configs = []; $uniques = []; foreach ($this->_storeManager->getStores() as $store) { /*@var $store \Magento\Store\Model\Store */ $active = $this->_scopeConfig->isSetFlag('paypal/fetch_reports/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store); if (!$active && $automaticMode) { continue; } $cfg = ['hostname' => $this->_scopeConfig->getValue('paypal/fetch_reports/ftp_ip', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store), 'path' => $this->_scopeConfig->getValue('paypal/fetch_reports/ftp_path', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store), 'username' => $this->_scopeConfig->getValue('paypal/fetch_reports/ftp_login', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store), 'password' => $this->_scopeConfig->getValue('paypal/fetch_reports/ftp_password', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store), 'sandbox' => $this->_scopeConfig->getValue('paypal/fetch_reports/ftp_sandbox', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store)]; if (empty($cfg['username']) || empty($cfg['password'])) { continue; } if (empty($cfg['hostname']) || $cfg['sandbox']) { $cfg['hostname'] = $cfg['sandbox'] ? self::SANDBOX_REPORTS_HOSTNAME : self::REPORTS_HOSTNAME; } if (empty($cfg['path']) || $cfg['sandbox']) { $cfg['path'] = self::REPORTS_PATH; } // avoid duplicates if (in_array(serialize($cfg), $uniques)) { continue; } $uniques[] = serialize($cfg); $configs[] = $cfg; } return $configs; }
/** * @return \Magento\Framework\View\Result\Page */ public function execute() { $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->set(__('Authors')); $resultPage->getConfig()->setDescription($this->scopeConfig->getValue(self::META_DESCRIPTION_CONFIG_PATH, ScopeInterface::SCOPE_STORE)); $resultPage->getConfig()->setKeywords($this->scopeConfig->getValue(self::META_KEYWORDS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)); if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) { /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbsBlock */ $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs'); if ($breadcrumbsBlock) { $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'link' => $this->_url->getUrl('')]); $breadcrumbsBlock->addCrumb('authors', ['label' => __('Authors')]); } } return $resultPage; }
/** * Retrieve config flag for store by field * * @param string $field * @return bool * @SuppressWarnings(PHPMD.BooleanGetMethodName) * @api */ public function getConfigFlag($field) { if (empty($this->_code)) { return false; } $path = 'carriers/' . $this->_code . '/' . $field; return $this->_scopeConfig->isSetFlag($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $this->getStore()); }
/** * Check is allowed guest checkout if quote contain downloadable product(s) * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $store = $observer->getEvent()->getStore(); $result = $observer->getEvent()->getResult(); $result->setIsAllowed(true); if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_DISABLE_GUEST_CHECKOUT, ScopeInterface::SCOPE_STORE, $store)) { return $this; } /* @var $quote \Magento\Quote\Model\Quote */ $quote = $observer->getEvent()->getQuote(); foreach ($quote->getAllItems() as $item) { if (($product = $item->getProduct()) && $product->getTypeId() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { $result->setIsAllowed(false); break; } } return $this; }
/** * Check if multishipping checkout is available * There should be a valid quote in checkout session. If not, only the config value will be returned * * @return bool */ public function isMultishippingCheckoutAvailable() { $quote = $this->getQuote(); $isMultiShipping = $this->scopeConfig->isSetFlag(self::XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); if (!$quote || !$quote->hasItems()) { return $isMultiShipping; } return $isMultiShipping && !$quote->hasItemsWithDecimalQty() && $quote->validateMinimumAmount(true) && $quote->getItemsSummaryQty() - $quote->getItemVirtualQty() > 0 && $quote->getItemsSummaryQty() <= $this->getMaximumQty() && !$quote->hasNominalItems(); }