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


PHP StoreManagerInterface::getStores方法代码示例

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


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

示例1: run

 /**
  * Run action
  *
  * @return void
  */
 public function run()
 {
     $this->_lastRecord = $this->_timestamp($this->_round($this->getLastRecordDate()));
     foreach ($this->_storeManager->getStores(false) as $store) {
         $this->_process($store->getId());
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:12,代码来源:Aggregation.php

示例2: deleteProductsFromStore

 /**
  * Delete products from flat table(s)
  *
  * @param int|array $productId
  * @param null|int $storeId
  * @return void
  */
 public function deleteProductsFromStore($productId, $storeId = null)
 {
     if (!is_array($productId)) {
         $productId = array($productId);
     }
     if (null === $storeId) {
         foreach ($this->storeManager->getStores() as $store) {
             $this->connection->delete($this->productIndexerHelper->getFlatTableName($store->getId()), array('entity_id IN(?)' => $productId));
         }
     } else {
         $this->connection->delete($this->productIndexerHelper->getFlatTableName((int) $storeId), array('entity_id IN(?)' => $productId));
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:20,代码来源:Eraser.php

示例3: process

 /**
  * Process path info
  *
  * @param string $pathInfo
  * @return string
  * @throws NoSuchEntityException
  */
 public function process($pathInfo)
 {
     $pathParts = $this->stripPathBeforeStorecode($pathInfo);
     $storeCode = $pathParts[0];
     $stores = $this->storeManager->getStores(false, true);
     if (isset($stores[$storeCode])) {
         $this->storeManager->setCurrentStore($storeCode);
         $path = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
     } else {
         $this->storeManager->setCurrentStore(\Magento\Store\Model\Store::DEFAULT_CODE);
         $path = '/' . implode('/', $pathParts);
     }
     return $path;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:PathProcessor.php

示例4: getCurrentStoreIds

 /**
  * Obtain all current store ids, depending on configuration
  *
  * @param null|array $predefinedStoreIds
  * @return array
  */
 public function getCurrentStoreIds(array $predefinedStoreIds = null)
 {
     $stores = array();
     // get all or specified stores
     if ($this->_storeManager->getStore()->getId() == 0) {
         if (null !== $predefinedStoreIds) {
             $stores = $predefinedStoreIds;
         } else {
             foreach ($this->_storeManager->getStores() as $store) {
                 $stores[] = $store->getId();
             }
         }
     } else {
         // get all stores, required by configuration in current store scope
         $productsScope = $this->_scopeConfig->getValue('catalog/recently_products/scope', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         switch ($productsScope) {
             case 'website':
                 $resourceStore = $this->_storeManager->getStore()->getWebsite()->getStores();
                 break;
             case 'group':
                 $resourceStore = $this->_storeManager->getStore()->getGroup()->getStores();
                 break;
             default:
                 $resourceStore = array($this->_storeManager->getStore());
                 break;
         }
         foreach ($resourceStore as $store) {
             $stores[] = $store->getId();
         }
     }
     foreach ($stores as $key => $store) {
         $stores[$key] = (int) $store;
     }
     return $stores;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:41,代码来源:Event.php

示例5: getEntitySummary

 /**
  * Return array of rating summary
  *
  * @param \Magento\Review\Model\Rating $object
  * @param boolean $onlyForCurrentStore
  * @return array
  */
 public function getEntitySummary($object, $onlyForCurrentStore = true)
 {
     $data = $this->_getEntitySummaryData($object);
     if ($onlyForCurrentStore) {
         foreach ($data as $row) {
             if ($row['store_id'] == $this->_storeManager->getStore()->getId()) {
                 $object->addData($row);
             }
         }
         return $object;
     }
     $stores = $this->_storeManager->getStores();
     $result = array();
     foreach ($data as $row) {
         $clone = clone $object;
         $clone->addData($row);
         $result[$clone->getStoreId()] = $clone;
     }
     $usedStoresId = array_keys($result);
     foreach ($stores as $store) {
         if (!in_array($store->getId(), $usedStoresId)) {
             $clone = clone $object;
             $clone->setCount(0);
             $clone->setSum(0);
             $clone->setStoreId($store->getId());
             $result[$store->getId()] = $clone;
         }
     }
     return array_values($result);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:37,代码来源:Rating.php

示例6: _afterLoad

 /**
  * Perform operations after collection load
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     if ($this->_previewFlag) {
         $items = $this->getColumnValues('page_id');
         $connection = $this->getConnection();
         if (count($items)) {
             $select = $connection->select()->from(array('cps' => $this->getTable('cms_page_store')))->where('cps.page_id IN (?)', $items);
             if ($result = $connection->fetchPairs($select)) {
                 foreach ($this as $item) {
                     if (!isset($result[$item->getData('page_id')])) {
                         continue;
                     }
                     if ($result[$item->getData('page_id')] == 0) {
                         $stores = $this->_storeManager->getStores(false, true);
                         $storeId = current($stores)->getId();
                         $storeCode = key($stores);
                     } else {
                         $storeId = $result[$item->getData('page_id')];
                         $storeCode = $this->_storeManager->getStore($storeId)->getCode();
                     }
                     $item->setData('_first_store_id', $storeId);
                     $item->setData('store_code', $storeCode);
                 }
             }
         }
     }
     return parent::_afterLoad();
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:33,代码来源:Collection.php

示例7: getStoresConfigByPath

 /**
  * Retrieve store Ids for $path with checking
  *
  * return array($storeId => $pathValue)
  *
  * @param string $path
  * @return array
  */
 public function getStoresConfigByPath($path)
 {
     $stores = $this->_storeManager->getStores(true);
     $storeValues = array();
     /** @var $store \Magento\Store\Model\Store */
     foreach ($stores as $store) {
         try {
             $value = $this->_config->getValue($path, ScopeInterface::SCOPE_STORE, $store->getCode());
             $storeValues[$store->getId()] = $value;
         } catch (NoSuchEntityException $e) {
             // Store doesn't really exist, so move on.
             continue;
         }
     }
     return $storeValues;
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:24,代码来源:StoresConfig.php

示例8: getSftpCredentials

 /**
  * 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
  */
 public function getSftpCredentials($automaticMode = false)
 {
     $configs = array();
     $uniques = array();
     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 = array('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;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:36,代码来源:Settlement.php

示例9: _initStores

 /**
  * Initialize stores data
  *
  * @param bool $withDefault
  * @return $this
  */
 protected function _initStores($withDefault = false)
 {
     /** @var $store \Magento\Store\Model\Store */
     foreach ($this->_storeManager->getStores($withDefault) as $store) {
         $this->_storeCodeToId[$store->getCode()] = $store->getId();
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:14,代码来源:AbstractEav.php

示例10: getStoreOptionHash

 /**
  * Get store views as id => name associative array
  *
  * @param bool $withDefault
  * @param string $attribute
  * @return array
  */
 public function getStoreOptionHash($withDefault = false, $attribute = 'name')
 {
     $options = array();
     foreach ($this->_storeManager->getStores((bool) $withDefault && $this->_isAdminScopeAllowed) as $store) {
         $options[$store->getId()] = $store->getDataUsingMethod($attribute);
     }
     return $options;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:Store.php

示例11: process

 /**
  * Process path info
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @param string $pathInfo
  * @return string
  */
 public function process(\Magento\Framework\App\RequestInterface $request, $pathInfo)
 {
     $pathParts = explode('/', ltrim($pathInfo, '/'), 2);
     $storeCode = $pathParts[0];
     $stores = $this->_storeManager->getStores(false, true);
     if (isset($stores[$storeCode]) && $stores[$storeCode]->isUseStoreInUrl()) {
         if (!$request->isDirectAccessFrontendName($storeCode)) {
             $this->_storeManager->setCurrentStore($storeCode);
             $pathInfo = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
             return $pathInfo;
         } elseif (!empty($storeCode)) {
             $request->setActionName('noroute');
             return $pathInfo;
         }
         return $pathInfo;
     }
     return $pathInfo;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:25,代码来源:PathInfoProcessor.php

示例12: _initStores

 /**
  * Initialize stores hash
  *
  * @return $this
  */
 protected function _initStores()
 {
     /** @var $store \Magento\Store\Model\Store */
     foreach ($this->_storeManager->getStores(true) as $store) {
         $this->_storeIdToCode[$store->getId()] = $store->getCode();
     }
     ksort($this->_storeIdToCode);
     // to ensure that 'admin' store (ID is zero) goes first
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:AbstractEntity.php

示例13: generateForDefaultStore

 /**
  * Generate list of urls for default store
  *
  * @return \Magento\UrlRedirect\Service\V1\Data\UrlRewrite[]
  */
 protected function generateForDefaultStore()
 {
     $urls = [];
     foreach ($this->storeManager->getStores() as $store) {
         if ($this->catalogUrlRewriteHelper->isNeedCreateUrlRewrite($store->getStoreId(), $this->product->getId())) {
             $urls = array_merge($urls, $this->generateForStore($store->getStoreId()));
         }
     }
     return $urls;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:ProductUrlGenerator.php

示例14: joinStoreTitles

 /**
  * Joins store titles for rates
  *
  * @return $this
  */
 public function joinStoreTitles()
 {
     $storeCollection = $this->_storeManager->getStores(true);
     foreach ($storeCollection as $store) {
         $tableAlias = sprintf('title_table_%s', $store->getId());
         $joinCondition = implode(' AND ', array("main_table.tax_calculation_rate_id = {$tableAlias}.tax_calculation_rate_id", $this->getConnection()->quoteInto($tableAlias . '.store_id = ?', $store->getId())));
         $this->_select->joinLeft(array($tableAlias => $this->getTable('tax_calculation_rate_title')), $joinCondition, array($tableAlias => 'value'));
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:Collection.php

示例15: reindex

 /**
  * Run reindexation
  *
  * @return void
  */
 protected function reindex()
 {
     foreach ($this->storeManager->getStores() as $store) {
         if ($this->getPathFromCategoryId($store->getRootCategoryId())) {
             $this->reindexRootCategory($store);
             $this->reindexAnchorCategories($store);
             $this->reindexNonAnchorCategories($store);
         }
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:AbstractAction.php


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