本文整理汇总了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());
}
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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']];
}
示例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;
}
示例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;
}
示例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);
}
}