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


PHP Category::getStoreId方法代码示例

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


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

示例1: aroundGetUrlInstance

 public function aroundGetUrlInstance(Category $category, \Closure $proceed)
 {
     if ($category->getStoreId() == 0) {
         return $proceed();
     } else {
         return $this->objectManager->create(self::FRONTEND_URL)->setStoreId($category->getStoreId());
     }
 }
开发者ID:algolia,项目名称:algoliasearch-magento-2,代码行数:8,代码来源:CategoryUrlPlugin.php

示例2: generate

 /**
  * {@inheritdoc}
  */
 public function generate($category)
 {
     $this->category = $category;
     $storeId = $this->category->getStoreId();
     $urls = $this->isGlobalScope($storeId) ? $this->generateForGlobalScope() : $this->generateForSpecificStoreView($storeId);
     $this->category = null;
     return $urls;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:CategoryUrlRewriteGenerator.php

示例3: generate

 /**
  * {@inheritdoc}
  */
 public function generate($category)
 {
     $this->category = $category;
     $storeId = $this->category->getStoreId();
     $urls = $this->catalogUrlRewriteHelper->isDefaultStore($storeId) ? $this->generateForDefaultStore() : $this->generateForStore($storeId);
     $this->category = null;
     return $urls;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:CategoryUrlGenerator.php

示例4: testSetStoreIdWithNonNumericValue

 /**
  * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  * @magentoAppIsolation enabled
  * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1
  */
 public function testSetStoreIdWithNonNumericValue()
 {
     /** @var $store \Magento\Store\Model\Store */
     $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Store\\Model\\Store');
     $store->load('fixturestore');
     $this->assertNotEquals($this->_model->getStoreId(), $store->getId());
     $this->_model->setStoreId('fixturestore');
     $this->assertEquals($this->_model->getStoreId(), $store->getId());
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:14,代码来源:CategoryTest.php

示例5: generateProductUrlRewrites

 /**
  * Generate url rewrites for products assigned to category
  *
  * @param Category $category
  * @return array
  */
 public function generateProductUrlRewrites(Category $category)
 {
     $this->isSkippedProduct = [];
     $saveRewriteHistory = $category->getData('save_rewrites_history');
     $storeId = $category->getStoreId();
     $productUrls = [];
     if ($category->getAffectedProductIds()) {
         $this->isSkippedProduct = $category->getAffectedProductIds();
         $collection = $this->productCollectionFactory->create()->setStoreId($storeId)->addIdFilter($category->getAffectedProductIds())->addAttributeToSelect('name')->addAttributeToSelect('url_key')->addAttributeToSelect('url_path');
         foreach ($collection as $product) {
             $product->setStoreId($storeId);
             $product->setData('save_rewrites_history', $saveRewriteHistory);
             $productUrls = array_merge($productUrls, $this->productUrlRewriteGenerator->generate($product));
         }
     } else {
         $productUrls = array_merge($productUrls, $this->getCategoryProductsUrlRewrites($category, $storeId, $saveRewriteHistory));
     }
     foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
         $productUrls = array_merge($productUrls, $this->getCategoryProductsUrlRewrites($childCategory, $storeId, $saveRewriteHistory));
     }
     return $productUrls;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:28,代码来源:UrlRewriteHandler.php

示例6: getUrlPathWithSuffix

 /**
  * Get category url path
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param int $storeId
  * @return string
  */
 public function getUrlPathWithSuffix($category, $storeId = null)
 {
     if ($storeId === null) {
         $storeId = $category->getStoreId();
     }
     return $this->getUrlPath($category) . $this->getCategoryUrlSuffix($storeId);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:14,代码来源:CategoryUrlPathGenerator.php

示例7: getChildren

 /**
  * Return children ids of category
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param boolean $recursive
  * @return array
  */
 public function getChildren($category, $recursive = true)
 {
     $attributeId = (int) $this->_getIsActiveAttributeId();
     $backendTable = $this->getTable(array($this->getEntityTablePrefix(), 'int'));
     $adapter = $this->_getReadAdapter();
     $checkSql = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value');
     $bind = array('attribute_id' => $attributeId, 'store_id' => $category->getStoreId(), 'scope' => 1, 'c_path' => $category->getPath() . '/%');
     $select = $this->_getReadAdapter()->select()->from(array('m' => $this->getEntityTable()), 'entity_id')->joinLeft(array('d' => $backendTable), 'd.attribute_id = :attribute_id AND d.store_id = 0 AND d.entity_id = m.entity_id', array())->joinLeft(array('c' => $backendTable), 'c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.entity_id = m.entity_id', array())->where($checkSql . ' = :scope')->where($adapter->quoteIdentifier('path') . ' LIKE :c_path');
     if (!$recursive) {
         $select->where($adapter->quoteIdentifier('level') . ' <= :c_level');
         $bind['c_level'] = $category->getLevel() + 1;
     }
     return $adapter->fetchCol($select, $bind);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:Category.php

示例8: getChildren

 /**
  * Return children ids of category
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param boolean $recursive
  * @return array
  */
 public function getChildren($category, $recursive = true)
 {
     $linkField = $this->getLinkField();
     $attributeId = $this->getIsActiveAttributeId();
     $backendTable = $this->getTable([$this->getEntityTablePrefix(), 'int']);
     $connection = $this->getConnection();
     $checkSql = $connection->getCheckSql('c.value_id > 0', 'c.value', 'd.value');
     $linkField = $this->getLinkField();
     $bind = ['attribute_id' => $attributeId, 'store_id' => $category->getStoreId(), 'scope' => 1, 'c_path' => $category->getPath() . '/%'];
     $select = $this->getConnection()->select()->from(['m' => $this->getEntityTable()], 'entity_id')->joinLeft(['d' => $backendTable], "d.attribute_id = :attribute_id AND d.store_id = 0 AND d.{$linkField} = m.{$linkField}", [])->joinLeft(['c' => $backendTable], "c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.{$linkField} = m.{$linkField}", [])->where($checkSql . ' = :scope')->where($connection->quoteIdentifier('path') . ' LIKE :c_path');
     if (!$recursive) {
         $select->where($connection->quoteIdentifier('level') . ' <= :c_level');
         $bind['c_level'] = $category->getLevel() + 1;
     }
     return $connection->fetchCol($select, $bind);
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:23,代码来源:Category.php

示例9: getObject

 public function getObject(Category $category)
 {
     /** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
     $productCollection = $category->getProductCollection();
     $productCollection = $productCollection->addMinimalPrice();
     $category->setProductCount($productCollection->getSize());
     $transport = new DataObject();
     $this->eventManager->dispatch('algolia_category_index_before', ['category' => $category, 'custom_data' => $transport]);
     $customData = $transport->getData();
     $storeId = $category->getStoreId();
     $category->getUrlInstance()->setStore($storeId);
     $path = '';
     foreach ($category->getPathIds() as $categoryId) {
         if ($path != '') {
             $path .= ' / ';
         }
         $path .= $this->getCategoryName($categoryId, $storeId);
     }
     $image_url = null;
     try {
         $image_url = $category->getImageUrl();
     } catch (\Exception $e) {
         /* no image, no default: not fatal */
     }
     $data = ['objectID' => $category->getId(), 'name' => $category->getName(), 'path' => $path, 'level' => $category->getLevel(), 'url' => $category->getUrl(), 'include_in_menu' => $category->getIncludeInMenu(), '_tags' => ['category'], 'popularity' => 1, 'product_count' => $category->getProductCount()];
     if (!empty($image_url)) {
         $data['image_url'] = $image_url;
     }
     foreach ($this->config->getCategoryAdditionalAttributes($storeId) as $attribute) {
         $value = $category->getData($attribute['attribute']);
         $attribute_resource = $category->getResource()->getAttribute($attribute['attribute']);
         if ($attribute_resource) {
             $value = $attribute_resource->getFrontend()->getValue($category);
         }
         if (isset($data[$attribute['attribute']])) {
             $value = $data[$attribute['attribute']];
         }
         if ($value) {
             $data[$attribute['attribute']] = $value;
         }
     }
     $data = array_merge($data, $customData);
     foreach ($data as &$data0) {
         $data0 = $this->try_cast($data0);
     }
     return $data;
 }
开发者ID:algolia,项目名称:algoliasearch-magento-2,代码行数:47,代码来源:CategoryHelper.php

示例10: getChildren

 /**
  * Return children ids of category
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param bool $recursive
  * @param bool $isActive
  * @return array
  */
 public function getChildren($category, $recursive = true, $isActive = true)
 {
     $select = $this->_getReadAdapter()->select()->from($this->getMainStoreTable($category->getStoreId()), 'entity_id')->where('path LIKE ?', "{$category->getPath()}/%");
     if (!$recursive) {
         $select->where('level <= ?', $category->getLevel() + 1);
     }
     if ($isActive) {
         $select->where('is_active = ?', '1');
     }
     $_categories = $this->_getReadAdapter()->fetchAll($select);
     $categoriesIds = [];
     foreach ($_categories as $_category) {
         $categoriesIds[] = $_category['entity_id'];
     }
     return $categoriesIds;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:24,代码来源:Flat.php

示例11: getCategoryBreadcrumb

 /**
  * Return a mini-breadcrumb for a category
  *
  * @param \Magento\Catalog\Model\Category $category The category
  *
  * @return array
  */
 private function getCategoryBreadcrumb(\Magento\Catalog\Model\Category $category)
 {
     $path = $category->getPath();
     $rawPath = explode('/', $path);
     // First occurence is root category (1), second is root category of store.
     $rawPath = array_slice($rawPath, 2);
     // Last occurence is the category displayed.
     array_pop($rawPath);
     $breadcrumb = [];
     foreach ($rawPath as $categoryId) {
         $breadcrumb[] = html_entity_decode($this->getCategoryNameById($categoryId, $category->getStoreId()));
     }
     return $breadcrumb;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:21,代码来源:ItemFactory.php

示例12: _getCodeData

 /**
  * Get data for saving code model
  *
  * @return array
  */
 protected function _getCodeData()
 {
     return ['entity_type' => \Magento\GoogleOptimizer\Model\Code::ENTITY_TYPE_CATEGORY, 'entity_id' => $this->_category->getId(), 'store_id' => $this->_category->getStoreId(), 'experiment_script' => $this->_params['experiment_script']];
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:Save.php

示例13: generateCategoryUrlKeyPath

 /**
  * Generate category url key path
  *
  * @param \Magento\Catalog\Model\Category $category
  * @return string
  */
 public function generateCategoryUrlKeyPath($category)
 {
     $parentPath = $this->categoryHelper->getCategoryUrlPath('', true, $category->getStoreId());
     $urlKey = $category->getUrlKey() == '' ? $category->formatUrlKey($category->getName()) : $category->formatUrlKey($category->getUrlKey());
     return $parentPath . $urlKey;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:12,代码来源:Data.php

示例14: addUseDefaultSettings

 /**
  * Add use default settings
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param array $categoryData
  * @return array
  */
 protected function addUseDefaultSettings($category, $categoryData)
 {
     if ($category->getExistsStoreValueFlag('url_key') || $category->getStoreId() === Store::DEFAULT_STORE_ID) {
         $categoryData['use_default']['url_key'] = false;
     } else {
         $categoryData['use_default']['url_key'] = true;
     }
     return $categoryData;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:16,代码来源:DataProvider.php

示例15: getStoreId

 /**
  * {@inheritdoc}
  */
 public function getStoreId()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getStoreId');
     if (!$pluginInfo) {
         return parent::getStoreId();
     } else {
         return $this->___callPlugins('getStoreId', func_get_args(), $pluginInfo);
     }
 }
开发者ID:HaonanXu,项目名称:der-snack-backup,代码行数:12,代码来源:Interceptor.php


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