예제 #1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectMagento($output, true);
     if (!$input->getOption('format')) {
         $this->writeSection($output, 'Magento Stores - Base URLs');
     }
     $this->initMagento();
     foreach ($this->storeManager->getStores() as $store) {
         $table[$store->getId()] = array($store->getId(), $store->getCode(), $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB), $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true));
     }
     ksort($table);
     $this->getHelper('table')->setHeaders(array('id', 'code', 'unsecure_baseurl', 'secure_baseurl'))->renderByFormat($output, $table, $input->getOption('format'));
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * Perform operations after collection load
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     $items = $this->getColumnValues('page_id');
     if (count($items)) {
         $connection = $this->getConnection();
         $select = $connection->select()->from(['cps' => $this->getTable('cms_page_store')])->where('cps.page_id IN (?)', $items);
         $result = $connection->fetchPairs($select);
         if ($result) {
             foreach ($this as $item) {
                 $pageId = $item->getData('page_id');
                 if (!isset($result[$pageId])) {
                     continue;
                 }
                 if ($result[$pageId] == 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);
                 $item->setData('store_id', [$result[$pageId]]);
             }
         }
     }
     $this->_previewFlag = false;
     return parent::_afterLoad();
 }