Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
ProductUrlRewriteGenerator Class Reference

Public Member Functions

 __construct (CanonicalUrlRewriteGenerator $canonicalUrlRewriteGenerator, CurrentUrlRewritesRegenerator $currentUrlRewritesRegenerator, CategoriesUrlRewriteGenerator $categoriesUrlRewriteGenerator, ObjectRegistryFactory $objectRegistryFactory, StoreViewService $storeViewService, \Magento\Store\Model\StoreManagerInterface $storeManager)
 
 generate (Product $product, $rootCategoryId=null)
 

Data Fields

const ENTITY_TYPE = 'product'
 

Protected Member Functions

 isGlobalScope ($storeId)
 
 generateForGlobalScope ($productCategories, $product=null, $rootCategoryId=null)
 
 generateForSpecificStoreView ( $storeId, $productCategories, $product=null, $rootCategoryId=null)
 
 isCategoryProperForGenerating ($category, $storeId)
 

Protected Attributes

 $storeViewService
 
 $product
 
 $currentUrlRewritesRegenerator
 
 $categoriesUrlRewriteGenerator
 
 $canonicalUrlRewriteGenerator
 
 $objectRegistryFactory
 
 $productCategories
 
 $storeManager
 

Detailed Description

Definition at line 21 of file ProductUrlRewriteGenerator.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( CanonicalUrlRewriteGenerator  $canonicalUrlRewriteGenerator,
CurrentUrlRewritesRegenerator  $currentUrlRewritesRegenerator,
CategoriesUrlRewriteGenerator  $categoriesUrlRewriteGenerator,
ObjectRegistryFactory  $objectRegistryFactory,
StoreViewService  $storeViewService,
\Magento\Store\Model\StoreManagerInterface  $storeManager 
)
Parameters
\Magento\CatalogUrlRewrite\Model\Product\CanonicalUrlRewriteGenerator$canonicalUrlRewriteGenerator
\Magento\CatalogUrlRewrite\Model\Product\CurrentUrlRewritesRegenerator$currentUrlRewritesRegenerator
\Magento\CatalogUrlRewrite\Model\Product\CategoriesUrlRewriteGenerator$categoriesUrlRewriteGenerator
\Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory$objectRegistryFactory
\Magento\CatalogUrlRewrite\Service\V1\StoreViewService$storeViewService
\Magento\Store\Model\StoreManagerInterface$storeManager

Definition at line 89 of file ProductUrlRewriteGenerator.php.

Member Function Documentation

◆ generate()

generate ( Product  $product,
  $rootCategoryId = null 
)

Generate product url rewrites

Parameters
\Magento\Catalog\Model\Product$product
int | null$rootCategoryId
Returns
\Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]

Definition at line 128 of file ProductUrlRewriteGenerator.php.

129  {
130  if ($product->getVisibility() == Visibility::VISIBILITY_NOT_VISIBLE) {
131  return [];
132  }
133 
134  $storeId = $product->getStoreId();
135 
136  $productCategories = $product->getCategoryCollection()
137  ->addAttributeToSelect('url_key')
138  ->addAttributeToSelect('url_path');
139 
140  $urls = $this->isGlobalScope($storeId)
143 
144  return $urls;
145  }
generateForGlobalScope($productCategories, $product=null, $rootCategoryId=null)
generateForSpecificStoreView( $storeId, $productCategories, $product=null, $rootCategoryId=null)

◆ generateForGlobalScope()

generateForGlobalScope (   $productCategories,
  $product = null,
  $rootCategoryId = null 
)
protected

Generate list of urls for global scope

Deprecated:
100.1.4
Parameters
\Magento\Framework\Data\Collection$productCategories
\Magento\Catalog\Model\Product | null$product
int | null$rootCategoryId
Returns
\Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]

Definition at line 168 of file ProductUrlRewriteGenerator.php.

169  {
170  return $this->getProductScopeRewriteGenerator()->generateForGlobalScope(
172  $product,
174  );
175  }

◆ generateForSpecificStoreView()

generateForSpecificStoreView (   $storeId,
  $productCategories,
  $product = null,
  $rootCategoryId = null 
)
protected

Generate list of urls for specific store view

Deprecated:
100.1.4
Parameters
int$storeId
\Magento\Framework\Data\Collection$productCategories
Product | null$product
int | null$rootCategoryId
Returns
\Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]

Definition at line 187 of file ProductUrlRewriteGenerator.php.

◆ isCategoryProperForGenerating()

isCategoryProperForGenerating (   $category,
  $storeId 
)
protected
Deprecated:
100.1.4
Parameters
\Magento\Catalog\Model\Category$category
int$storeId
Returns
bool

Definition at line 203 of file ProductUrlRewriteGenerator.php.

204  {
205  return $this->getProductScopeRewriteGenerator()->isCategoryProperForGenerating($category, $storeId);
206  }

◆ isGlobalScope()

isGlobalScope (   $storeId)
protected

Check is global scope

Deprecated:
100.1.4
Parameters
int | null$storeId
Returns
bool

Definition at line 154 of file ProductUrlRewriteGenerator.php.

155  {
156  return $this->getProductScopeRewriteGenerator()->isGlobalScope($storeId);
157  }

Field Documentation

◆ $canonicalUrlRewriteGenerator

$canonicalUrlRewriteGenerator
protected

Definition at line 56 of file ProductUrlRewriteGenerator.php.

◆ $categoriesUrlRewriteGenerator

$categoriesUrlRewriteGenerator
protected

Definition at line 50 of file ProductUrlRewriteGenerator.php.

◆ $currentUrlRewritesRegenerator

$currentUrlRewritesRegenerator
protected

Definition at line 44 of file ProductUrlRewriteGenerator.php.

◆ $objectRegistryFactory

$objectRegistryFactory
protected

Definition at line 62 of file ProductUrlRewriteGenerator.php.

◆ $product

$product
protected

Definition at line 38 of file ProductUrlRewriteGenerator.php.

◆ $productCategories

$productCategories
protected

Definition at line 68 of file ProductUrlRewriteGenerator.php.

◆ $storeManager

$storeManager
protected

Definition at line 74 of file ProductUrlRewriteGenerator.php.

◆ $storeViewService

$storeViewService
protected

Definition at line 32 of file ProductUrlRewriteGenerator.php.

◆ ENTITY_TYPE

const ENTITY_TYPE = 'product'

Entity type code

Definition at line 26 of file ProductUrlRewriteGenerator.php.


The documentation for this class was generated from the following file: