Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CanonicalUrlRewriteGenerator.php
Go to the documentation of this file.
1 <?php
7 
12 use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory;
13 
15 {
20 
24  protected $urlRewriteFactory;
25 
31  {
32  $this->productUrlPathGenerator = $productUrlPathGenerator;
33  $this->urlRewriteFactory = $urlRewriteFactory;
34  }
35 
43  public function generate($storeId, Product $product)
44  {
45  return [
46  $this->urlRewriteFactory->create()
48  ->setEntityId($product->getId())
49  ->setRequestPath($this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId))
50  ->setTargetPath($this->productUrlPathGenerator->getCanonicalUrlPath($product))
52  ];
53  }
54 }
__construct(ProductUrlPathGenerator $productUrlPathGenerator, UrlRewriteFactory $urlRewriteFactory)