当前位置: 首页>>代码示例>>PHP>>正文


PHP StoreManagerInterface::getWebsite方法代码示例

本文整理汇总了PHP中Magento\Framework\StoreManagerInterface::getWebsite方法的典型用法代码示例。如果您正苦于以下问题:PHP StoreManagerInterface::getWebsite方法的具体用法?PHP StoreManagerInterface::getWebsite怎么用?PHP StoreManagerInterface::getWebsite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\StoreManagerInterface的用法示例。


在下文中一共展示了StoreManagerInterface::getWebsite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: aroundDispatch

 /**
  * @param \Magento\Framework\App\Action\Action $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  * @return mixed
  */
 public function aroundDispatch(\Magento\Framework\App\Action\Action $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     $defaultStore = $this->storeManager->getWebsite()->getDefaultStore();
     $this->httpContext->setValue(\Magento\Core\Helper\Data::CONTEXT_CURRENCY, $this->session->getCurrencyCode(), $defaultStore->getDefaultCurrency()->getCode());
     $this->httpContext->setValue(\Magento\Core\Helper\Data::CONTEXT_STORE, $this->httpRequest->getParam('___store', $defaultStore->getStoreCodeFromCookie()), $this->storeManager->getWebsite()->getDefaultStore()->getCode());
     return $proceed($request);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:13,代码来源:Context.php

示例2: dispatch

 /**
  * 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();
             }
         }
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:31,代码来源:CustomerQuote.php

示例3: _getConfigUrl

 /**
  * Get url for config settings where base url option can be changed
  *
  * @return string
  */
 protected function _getConfigUrl()
 {
     $output = '';
     $defaultUnsecure = $this->_config->getValue(\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default');
     $defaultSecure = $this->_config->getValue(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default');
     if ($defaultSecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER || $defaultUnsecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER) {
         $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web'));
     } else {
         /** @var $dataCollection \Magento\Core\Model\Resource\Config\Data\Collection */
         $dataCollection = $this->_configValueFactory->create()->getCollection();
         $dataCollection->addValueFilter(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER);
         /** @var $data \Magento\Framework\App\Config\ValueInterface */
         foreach ($dataCollection as $data) {
             if ($data->getScope() == 'stores') {
                 $code = $this->_storeManager->getStore($data->getScopeId())->getCode();
                 $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web', 'store' => $code));
                 break;
             } elseif ($data->getScope() == 'websites') {
                 $code = $this->_storeManager->getWebsite($data->getScopeId())->getCode();
                 $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web', 'website' => $code));
                 break;
             }
         }
     }
     return $output;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:31,代码来源:Baseurl.php

示例4: getScope

 /**
  * {@inheritdoc}
  * @throws \Magento\Framework\App\InitException
  */
 public function getScope($scopeId = null)
 {
     $scope = $this->_storeManager->getWebsite($scopeId);
     if (!$scope instanceof \Magento\Framework\App\ScopeInterface) {
         throw new \Magento\Framework\App\InitException('Invalid scope object');
     }
     return $scope;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:12,代码来源:Website.php

示例5: _afterLoad

 /**
  * Substitute empty value with Default country.
  *
  * @return void
  */
 protected function _afterLoad()
 {
     $value = (string) $this->getValue();
     if (empty($value)) {
         if ($this->getWebsite()) {
             $defaultCountry = $this->_storeManager->getWebsite($this->getWebsite())->getConfig(\Magento\Core\Helper\Data::XML_PATH_DEFAULT_COUNTRY);
         } else {
             $defaultCountry = $this->_coreData->getDefaultCountry($this->getStore());
         }
         $this->setValue($defaultCountry);
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:17,代码来源:MerchantCountry.php

示例6: execute

 /**
  * Export shipping table rates in csv format
  *
  * @return ResponseInterface
  */
 public function execute()
 {
     $fileName = 'tablerates.csv';
     /** @var $gridBlock \Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid */
     $gridBlock = $this->_view->getLayout()->createBlock('Magento\\OfflineShipping\\Block\\Adminhtml\\Carrier\\Tablerate\\Grid');
     $website = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'));
     if ($this->getRequest()->getParam('conditionName')) {
         $conditionName = $this->getRequest()->getParam('conditionName');
     } else {
         $conditionName = $website->getConfig('carriers/tablerate/condition_name');
     }
     $gridBlock->setWebsiteId($website->getId())->setConditionName($conditionName);
     $content = $gridBlock->getCsvFile();
     return $this->_fileFactory->create($fileName, $content, \Magento\Framework\App\Filesystem::VAR_DIR);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:20,代码来源:ExportTablerates.php

示例7: _prepareWebsiteDateTable

 /**
  * Prepare website current dates table
  *
  * @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction
  */
 protected function _prepareWebsiteDateTable()
 {
     $write = $this->_getConnection();
     $baseCurrency = $this->_config->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE);
     $select = $write->select()->from(array('cw' => $this->_getTable('store_website')), array('website_id'))->join(array('csg' => $this->_getTable('store_group')), 'cw.default_group_id = csg.group_id', array('store_id' => 'default_store_id'))->where('cw.website_id != 0');
     $data = array();
     foreach ($write->fetchAll($select) as $item) {
         /** @var $website \Magento\Store\Model\Website */
         $website = $this->_storeManager->getWebsite($item['website_id']);
         if ($website->getBaseCurrencyCode() != $baseCurrency) {
             $rate = $this->_currencyFactory->create()->load($baseCurrency)->getRate($website->getBaseCurrencyCode());
             if (!$rate) {
                 $rate = 1;
             }
         } else {
             $rate = 1;
         }
         /** @var $store \Magento\Store\Model\Store */
         $store = $this->_storeManager->getStore($item['store_id']);
         if ($store) {
             $timestamp = $this->_localeDate->scopeTimeStamp($store);
             $data[] = array('website_id' => $website->getId(), 'website_date' => $this->_dateTime->formatDate($timestamp, false), 'rate' => $rate);
         }
     }
     $table = $this->_getTable('catalog_product_index_website');
     $this->_emptyTable($table);
     if ($data) {
         $write->insertMultiple($table, $data);
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:36,代码来源:AbstractAction.php

示例8: initScope

 /**
  * Get scope name and scopeId
  * @todo refactor to scope resolver
  * @return void
  */
 private function initScope()
 {
     if (is_null($this->getSection())) {
         $this->setSection('');
     }
     if (is_null($this->getWebsite())) {
         $this->setWebsite('');
     }
     if (is_null($this->getStore())) {
         $this->setStore('');
     }
     if ($this->getStore()) {
         $scope = 'stores';
         $store = $this->_storeManager->getStore($this->getStore());
         $scopeId = (int) $store->getId();
         $scopeCode = $store->getCode();
     } elseif ($this->getWebsite()) {
         $scope = 'websites';
         $website = $this->_storeManager->getWebsite($this->getWebsite());
         $scopeId = (int) $website->getId();
         $scopeCode = $website->getCode();
     } else {
         $scope = 'default';
         $scopeId = 0;
         $scopeCode = '';
     }
     $this->setScope($scope);
     $this->setScopeId($scopeId);
     $this->setScopeCode($scopeCode);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:35,代码来源:Config.php

示例9: __construct

 /**
  * @param \Magento\Customer\Model\Config\Share $configShare
  * @param \Magento\Framework\StoreManagerInterface $storeManager
  * @param string $namespace
  * @param array $data
  */
 public function __construct(\Magento\Customer\Model\Config\Share $configShare, \Magento\Framework\StoreManagerInterface $storeManager, $namespace = 'customer', array $data = array())
 {
     if ($configShare->isWebsiteScope()) {
         $namespace .= '_' . $storeManager->getWebsite()->getCode();
     }
     parent::__construct($namespace, $data);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:13,代码来源:Storage.php

示例10: saveItemTitleAndPrice

 /**
  * Save title and price of link item
  *
  * @param \Magento\Downloadable\Model\Link $linkObject
  * @return $this
  */
 public function saveItemTitleAndPrice($linkObject)
 {
     $writeAdapter = $this->_getWriteAdapter();
     $linkTitleTable = $this->getTable('downloadable_link_title');
     $linkPriceTable = $this->getTable('downloadable_link_price');
     $select = $writeAdapter->select()->from($this->getTable('downloadable_link_title'))->where('link_id=:link_id AND store_id=:store_id');
     $bind = array(':link_id' => $linkObject->getId(), ':store_id' => (int) $linkObject->getStoreId());
     if ($writeAdapter->fetchOne($select, $bind)) {
         $where = array('link_id = ?' => $linkObject->getId(), 'store_id = ?' => (int) $linkObject->getStoreId());
         if ($linkObject->getUseDefaultTitle()) {
             $writeAdapter->delete($linkTitleTable, $where);
         } else {
             $insertData = array('title' => $linkObject->getTitle());
             $writeAdapter->update($linkTitleTable, $insertData, $where);
         }
     } else {
         if (!$linkObject->getUseDefaultTitle()) {
             $writeAdapter->insert($linkTitleTable, array('link_id' => $linkObject->getId(), 'store_id' => (int) $linkObject->getStoreId(), 'title' => $linkObject->getTitle()));
         }
     }
     $select = $writeAdapter->select()->from($linkPriceTable)->where('link_id=:link_id AND website_id=:website_id');
     $bind = array(':link_id' => $linkObject->getId(), ':website_id' => (int) $linkObject->getWebsiteId());
     if ($writeAdapter->fetchOne($select, $bind)) {
         $where = array('link_id = ?' => $linkObject->getId(), 'website_id = ?' => $linkObject->getWebsiteId());
         if ($linkObject->getUseDefaultPrice()) {
             $writeAdapter->delete($linkPriceTable, $where);
         } else {
             $writeAdapter->update($linkPriceTable, array('price' => $linkObject->getPrice()), $where);
         }
     } else {
         if (!$linkObject->getUseDefaultPrice()) {
             $dataToInsert[] = array('link_id' => $linkObject->getId(), 'website_id' => (int) $linkObject->getWebsiteId(), 'price' => (double) $linkObject->getPrice());
             if ($linkObject->getOrigData('link_id') != $linkObject->getLinkId()) {
                 $_isNew = true;
             } else {
                 $_isNew = false;
             }
             if ($linkObject->getWebsiteId() == 0 && $_isNew && !$this->_catalogData->isPriceGlobal()) {
                 $websiteIds = $linkObject->getProductWebsiteIds();
                 foreach ($websiteIds as $websiteId) {
                     $baseCurrency = $this->_configuration->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default');
                     $websiteCurrency = $this->_storeManager->getWebsite($websiteId)->getBaseCurrencyCode();
                     if ($websiteCurrency == $baseCurrency) {
                         continue;
                     }
                     $rate = $this->_createCurrency()->load($baseCurrency)->getRate($websiteCurrency);
                     if (!$rate) {
                         $rate = 1;
                     }
                     $newPrice = $linkObject->getPrice() * $rate;
                     $dataToInsert[] = array('link_id' => $linkObject->getId(), 'website_id' => (int) $websiteId, 'price' => $newPrice);
                 }
             }
             $writeAdapter->insertMultiple($linkPriceTable, $dataToInsert);
         }
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:64,代码来源:Link.php

示例11: getCondition

 /**
  * Get options for grid filter
  *
  * @return null|array
  */
 public function getCondition()
 {
     $id = $this->getValue();
     if (!$id) {
         return null;
     }
     $website = $this->_storeManager->getWebsite($id);
     return array('in' => $website->getStoresIds(true));
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:14,代码来源:Website.php

示例12: getDefaultCurrency

 /**
  * Retrieve default currency for selected store, website or website group
  * @todo: Refactor to ScopeDefiner
  * @param \Magento\Framework\App\RequestInterface $request
  * @return string
  */
 public function getDefaultCurrency(\Magento\Framework\App\RequestInterface $request)
 {
     if ($request->getParam('store')) {
         $store = $request->getParam('store');
         $currencyCode = $this->_storeManager->getStore($store)->getBaseCurrencyCode();
     } else {
         if ($request->getParam('website')) {
             $website = $request->getParam('website');
             $currencyCode = $this->_storeManager->getWebsite($website)->getBaseCurrencyCode();
         } else {
             if ($request->getParam('group')) {
                 $group = $request->getParam('group');
                 $currencyCode = $this->_storeManager->getGroup($group)->getWebsite()->getBaseCurrencyCode();
             } else {
                 $currencyCode = $this->_configuration->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default');
             }
         }
     }
     return $currencyCode;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:26,代码来源:DefaultLocator.php

示例13: delete

 /**
  * {@inheritdoc}
  */
 public function delete($productSku, $customerGroupId, $qty)
 {
     $product = $this->productRepository->get($productSku, true);
     if ($this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE) == 0) {
         $websiteId = 0;
     } else {
         $websiteId = $this->storeManager->getWebsite()->getId();
     }
     $this->priceModifier->removeTierPrice($product, $customerGroupId, $qty, $websiteId);
     return true;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:14,代码来源:TierPriceService.php

示例14: _getRuleProductsStmt

 /**
  * Get DB resource statement for processing query result
  *
  * @param int $fromDate
  * @param int $toDate
  * @param int|null $productId
  * @param int|null $websiteId
  * @return \Zend_Db_Statement_Interface
  */
 protected function _getRuleProductsStmt($fromDate, $toDate, $productId = null, $websiteId = null)
 {
     $read = $this->_getReadAdapter();
     /**
      * Sort order is important
      * It used for check stop price rule condition.
      * website_id   customer_group_id   product_id  sort_order
      *  1           1                   1           0
      *  1           1                   1           1
      *  1           1                   1           2
      * if row with sort order 1 will have stop flag we should exclude
      * all next rows for same product id from price calculation
      */
     $select = $read->select()->from(array('rp' => $this->getTable('catalogrule_product')))->where($read->quoteInto('rp.from_time = 0 or rp.from_time <= ?', $toDate) . ' OR ' . $read->quoteInto('rp.to_time = 0 or rp.to_time >= ?', $fromDate))->order(array('rp.website_id', 'rp.customer_group_id', 'rp.product_id', 'rp.sort_order', 'rp.rule_id'));
     if (!is_null($productId)) {
         $select->where('rp.product_id=?', $productId);
     }
     /**
      * Join default price and websites prices to result
      */
     $priceAttr = $this->_eavConfig->getAttribute(Product::ENTITY, 'price');
     $priceTable = $priceAttr->getBackend()->getTable();
     $attributeId = $priceAttr->getId();
     $joinCondition = '%1$s.entity_id=rp.product_id AND (%1$s.attribute_id=' . $attributeId . ') and %1$s.store_id=%2$s';
     $select->join(array('pp_default' => $priceTable), sprintf($joinCondition, 'pp_default', \Magento\Store\Model\Store::DEFAULT_STORE_ID), array('default_price' => 'pp_default.value'));
     if ($websiteId !== null) {
         $website = $this->_storeManager->getWebsite($websiteId);
         $defaultGroup = $website->getDefaultGroup();
         if ($defaultGroup instanceof \Magento\Store\Model\Group) {
             $storeId = $defaultGroup->getDefaultStoreId();
         } else {
             $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
         }
         $select->joinInner(array('product_website' => $this->getTable('catalog_product_website')), 'product_website.product_id=rp.product_id ' . 'AND rp.website_id=product_website.website_id ' . 'AND product_website.website_id=' . $websiteId, array());
         $tableAlias = 'pp' . $websiteId;
         $fieldAlias = 'website_' . $websiteId . '_price';
         $select->joinLeft(array($tableAlias => $priceTable), sprintf($joinCondition, $tableAlias, $storeId), array($fieldAlias => $tableAlias . '.value'));
     } else {
         foreach ($this->_storeManager->getWebsites() as $website) {
             $websiteId = $website->getId();
             $defaultGroup = $website->getDefaultGroup();
             if ($defaultGroup instanceof \Magento\Store\Model\Group) {
                 $storeId = $defaultGroup->getDefaultStoreId();
             } else {
                 $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
             }
             $tableAlias = 'pp' . $websiteId;
             $fieldAlias = 'website_' . $websiteId . '_price';
             $select->joinLeft(array($tableAlias => $priceTable), sprintf($joinCondition, $tableAlias, $storeId), array($fieldAlias => $tableAlias . '.value'));
         }
     }
     return $read->query($select);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:62,代码来源:Rule.php

示例15: _afterDelete

 /**
  * Processing object after delete data
  *
  * @return \Magento\Framework\Model\AbstractModel
  */
 protected function _afterDelete()
 {
     $result = parent::_afterDelete();
     if ($this->getScope() == \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES) {
         $attribute = $this->_eavConfig->getAttribute('customer_address', 'street');
         $website = $this->_storeManager->getWebsite($this->getScopeCode());
         $attribute->setWebsite($website);
         $attribute->load($attribute->getId());
         $attribute->setData('scope_multiline_count', null);
         $attribute->save();
     }
     return $result;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:18,代码来源:Street.php


注:本文中的Magento\Framework\StoreManagerInterface::getWebsite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。