本文整理匯總了PHP中Magento\Store\Model\Store::getRootCategoryId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Store::getRootCategoryId方法的具體用法?PHP Store::getRootCategoryId怎麽用?PHP Store::getRootCategoryId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Store\Model\Store
的用法示例。
在下文中一共展示了Store::getRootCategoryId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filterIdsByStore
/**
* Filter category ids by store
*
* @param int[] $ids
* @param \Magento\Store\Model\Store $store
* @return int[]
*/
protected function filterIdsByStore(array $ids, $store)
{
$rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
$rootIdExpr = $this->getReadAdapter()->quote((string) $rootId);
$rootCatIdExpr = $this->getReadAdapter()->quote("{$rootId}/{$store->getRootCategoryId()}");
$catIdExpr = $this->getReadAdapter()->quote("{$rootId}/{$store->getRootCategoryId()}/%");
$select = $this->getReadAdapter()->select()->from($this->getTableName('catalog_category_entity'), array('entity_id'))->where("path = {$rootIdExpr} OR path = {$rootCatIdExpr} OR path like {$catIdExpr}")->where('entity_id IN (?)', $ids);
$resultIds = array();
foreach ($this->getReadAdapter()->fetchAll($select) as $category) {
$resultIds[] = $category['entity_id'];
}
return $resultIds;
}
示例2: getRootCategoryId
/**
* {@inheritdoc}
*/
public function getRootCategoryId()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getRootCategoryId');
if (!$pluginInfo) {
return parent::getRootCategoryId();
} else {
return $this->___callPlugins('getRootCategoryId', func_get_args(), $pluginInfo);
}
}
示例3: getAllProducts
/**
* Get select for all products
*
* @param \Magento\Store\Model\Store $store
* @return \Magento\Framework\DB\Select
*/
protected function getAllProducts(\Magento\Store\Model\Store $store)
{
if (!isset($this->productsSelects[$store->getId()])) {
$statusAttributeId = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'status')->getId();
$visibilityAttributeId = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'visibility')->getId();
$metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
$linkField = $metadata->getLinkField();
$select = $this->connection->select()->from(['cp' => $this->getTable('catalog_product_entity')], [])->joinInner(['cpw' => $this->getTable('catalog_product_website')], 'cpw.product_id = cp.entity_id', [])->joinInner(['cpsd' => $this->getTable('catalog_product_entity_int')], 'cpsd.' . $linkField . ' = cp.' . $linkField . ' AND cpsd.store_id = 0' . ' AND cpsd.attribute_id = ' . $statusAttributeId, [])->joinLeft(['cpss' => $this->getTable('catalog_product_entity_int')], 'cpss.' . $linkField . ' = cp.' . $linkField . ' AND cpss.attribute_id = cpsd.attribute_id' . ' AND cpss.store_id = ' . $store->getId(), [])->joinInner(['cpvd' => $this->getTable('catalog_product_entity_int')], 'cpvd.' . $linkField . ' = cp.' . $linkField . ' AND cpvd.store_id = 0' . ' AND cpvd.attribute_id = ' . $visibilityAttributeId, [])->joinLeft(['cpvs' => $this->getTable('catalog_product_entity_int')], 'cpvs.' . $linkField . ' = cp.' . $linkField . ' AND cpvs.attribute_id = cpvd.attribute_id ' . ' AND cpvs.store_id = ' . $store->getId(), [])->joinLeft(['ccp' => $this->getTable('catalog_category_product')], 'ccp.product_id = cp.entity_id', [])->where('cpw.website_id = ?', $store->getWebsiteId())->where($this->connection->getIfNullSql('cpss.value', 'cpsd.value') . ' = ?', \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)->where($this->connection->getIfNullSql('cpvs.value', 'cpvd.value') . ' IN (?)', [\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG, \Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH, \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH])->group('cp.entity_id')->columns(['category_id' => new \Zend_Db_Expr($store->getRootCategoryId()), 'product_id' => 'cp.entity_id', 'position' => new \Zend_Db_Expr($this->connection->getCheckSql('ccp.product_id IS NOT NULL', 'ccp.position', '0')), 'is_parent' => new \Zend_Db_Expr($this->connection->getCheckSql('ccp.product_id IS NOT NULL', '1', '0')), 'store_id' => new \Zend_Db_Expr($store->getId()), 'visibility' => new \Zend_Db_Expr($this->connection->getIfNullSql('cpvs.value', 'cpvd.value'))]);
$this->productsSelects[$store->getId()] = $select;
}
return $this->productsSelects[$store->getId()];
}
示例4: getPreviewUrlCategory
/**
* Gets the absolute preview URL to a given store's category page.
* The category is the first one found in the database for the store.
* The preview url includes "nostodebug=true" parameter.
*
* @param Store $store the store to get the url for.
*
* @return string the url.
*/
public function getPreviewUrlCategory(Store $store)
{
$rootCatId = (int) $store->getRootCategoryId();
/** @noinspection PhpUndefinedNamespaceInspection */
/** @noinspection PhpUndefinedClassInspection */
/** @var \Magento\Catalog\Model\Resource\Category\Collection $collection */
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToFilter('is_active', ['eq' => 1]);
$collection->addAttributeToFilter('path', ['like' => "1/{$rootCatId}/%"]);
$collection->setCurPage(1);
$collection->setPageSize(1);
$collection->load();
foreach ($collection->getItems() as $category) {
/** @var \Magento\Catalog\Model\Category $category */
$url = $category->getUrl();
$url = $this->replaceQueryParamsInUrl(array('___store' => $store->getCode()), $url);
return $this->addNostoDebugParamToUrl($url);
}
return '';
}