Definition at line 8 of file ProductUrlPathGenerator.php.
◆ __construct()
- Parameters
-
\Magento\Store\Model\StoreManagerInterface | $storeManager | |
\Magento\Framework\App\Config\ScopeConfigInterface | $scopeConfig | |
CategoryUrlPathGenerator | $categoryUrlPathGenerator | |
\Magento\Catalog\Api\ProductRepositoryInterface | $productRepository | |
Definition at line 45 of file ProductUrlPathGenerator.php.
$categoryUrlPathGenerator
◆ getCanonicalUrlPath()
getCanonicalUrlPath |
( |
|
$product, |
|
|
|
$category = null |
|
) |
| |
Get canonical product url path
- Parameters
-
\Magento\Catalog\Model\Product | $product | |
\Magento\Catalog\Model\Category | null | $category | |
- Returns
- string
Definition at line 111 of file ProductUrlPathGenerator.php.
◆ getProductUrlSuffix()
getProductUrlSuffix |
( |
|
$storeId = null | ) |
|
|
protected |
Retrieve product rewrite suffix for store
- Parameters
-
- Returns
- string
Definition at line 147 of file ProductUrlPathGenerator.php.
150 $storeId = $this->storeManager->getStore()->getId();
153 if (!isset($this->productUrlSuffix[
$storeId])) {
154 $this->productUrlSuffix[
$storeId] = $this->scopeConfig->getValue(
155 self::XML_PATH_PRODUCT_URL_SUFFIX,
160 return $this->productUrlSuffix[
$storeId];
◆ getUrlKey()
Generate product url key based on url_key entered by merchant or product name
- Parameters
-
\Magento\Catalog\Model\Product | $product | |
- Returns
- string|null
Definition at line 123 of file ProductUrlPathGenerator.php.
126 return (
$product->getUrlKey() ===
false || empty($generatedProductUrlKey)) ?
null : $generatedProductUrlKey;
prepareProductUrlKey(\Magento\Catalog\Model\Product $product)
◆ getUrlPath()
getUrlPath |
( |
|
$product, |
|
|
|
$category = null |
|
) |
| |
Retrieve Product Url path (with category if exists)
- Parameters
-
\Magento\Catalog\Model\Product | $product | |
\Magento\Catalog\Model\Category | $category | |
- Returns
- string
Definition at line 65 of file ProductUrlPathGenerator.php.
75 : $this->categoryUrlPathGenerator->getUrlPath(
$category) .
'/' .
$path;
prepareProductDefaultUrlKey(\Magento\Catalog\Model\Product $product)
prepareProductUrlKey(\Magento\Catalog\Model\Product $product)
◆ getUrlPathWithSuffix()
getUrlPathWithSuffix |
( |
|
$product, |
|
|
|
$storeId, |
|
|
|
$category = null |
|
) |
| |
Retrieve Product Url path with suffix
- Parameters
-
\Magento\Catalog\Model\Product | $product | |
int | $storeId | |
\Magento\Catalog\Model\Category | $category | |
- Returns
- string
Definition at line 99 of file ProductUrlPathGenerator.php.
getUrlPath($product, $category=null)
getProductUrlSuffix($storeId=null)
◆ prepareProductDefaultUrlKey()
Prepare URL Key with stored product data (fallback for "Use Default Value" logic)
- Parameters
-
\Magento\Catalog\Model\Product | $product | |
- Returns
- string
Definition at line 84 of file ProductUrlPathGenerator.php.
86 $storedProduct = $this->productRepository->getById(
$product->getId());
87 $storedUrlKey = $storedProduct->getUrlKey();
88 return $storedUrlKey ?:
$product->formatUrlKey($storedProduct->getName());
◆ prepareProductUrlKey()
Prepare url key for product
- Parameters
-
\Magento\Catalog\Model\Product | $product | |
- Returns
- string
Definition at line 135 of file ProductUrlPathGenerator.php.
138 return $product->formatUrlKey($urlKey ===
'' || $urlKey ===
null ?
$product->getName() : $urlKey);
◆ $categoryUrlPathGenerator
$categoryUrlPathGenerator |
|
protected |
◆ $productRepository
◆ $productUrlSuffix
◆ $scopeConfig
◆ $storeManager
◆ XML_PATH_PRODUCT_URL_SUFFIX
const XML_PATH_PRODUCT_URL_SUFFIX = 'catalog/seo/product_url_suffix' |
The documentation for this class was generated from the following file: