Skip to content

Commit

Permalink
Merge pull request PrestaShop#21729 from micka-fdz/move-product-canon…
Browse files Browse the repository at this point in the history
…ical

Move product canonical url from tpl to controller
  • Loading branch information
Progi1984 authored Dec 16, 2020
2 parents 603fef9 + e4bfc32 commit 4e9fc2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 12 additions & 0 deletions controllers/front/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
use PrestaShop\PrestaShop\Adapter\Presenter\AbstractLazyArray;
use PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductLazyArray;
use PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingPresenter;
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
Expand Down Expand Up @@ -83,6 +84,17 @@ public function canonicalRedirection($canonical_url = '')
}
}

public function getCanonicalURL(): string
{
$product = $this->context->smarty->getTemplateVars('product');

if (!($product instanceof ProductLazyArray)) {
return '';
}

return $product->getCanonicalUrl();
}

/**
* Initialize product controller.
*
Expand Down
4 changes: 0 additions & 4 deletions themes/classic/templates/catalog/product.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
*}
{extends file=$layout}

{block name='head_seo' prepend}
<link rel="canonical" href="{$product.canonical_url}">
{/block}

{block name='head' append}
<meta property="og:type" content="product">
<meta property="og:url" content="{$urls.current_url}">
Expand Down

0 comments on commit 4e9fc2d

Please sign in to comment.