From 20f81b11dedae4161b48afaeba6b8a03e26040e6 Mon Sep 17 00:00:00 2001 From: mickael Date: Tue, 3 Nov 2020 10:58:51 +0100 Subject: [PATCH 1/6] Move product canonical url definition in ProductController --- controllers/front/ProductController.php | 7 +++++++ themes/classic/templates/catalog/product.tpl | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index e51ea7a6d3e7f..52fccf271bf02 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -83,6 +83,13 @@ public function canonicalRedirection($canonical_url = '') } } + public function getCanonicalUrl() + { + $product = $this->context->smarty->getTemplateVars('product'); + + return $product->getCanonicalUrl(); + } + /** * Initialize product controller. * diff --git a/themes/classic/templates/catalog/product.tpl b/themes/classic/templates/catalog/product.tpl index 4ff704a82fae8..3f1c054607ae3 100644 --- a/themes/classic/templates/catalog/product.tpl +++ b/themes/classic/templates/catalog/product.tpl @@ -24,10 +24,6 @@ *} {extends file=$layout} -{block name='head_seo' prepend} - -{/block} - {block name='head' append} From 2a35f6b417c03d8313ac4dad9551a7da5aec4d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Fernandez?= <50865159+micka-fdz@users.noreply.github.com> Date: Mon, 9 Nov 2020 11:50:25 +0100 Subject: [PATCH 2/6] Update controllers/front/ProductController.php Co-authored-by: Progi1984 --- controllers/front/ProductController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 52fccf271bf02..9f5d09bbad49d 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -83,7 +83,7 @@ public function canonicalRedirection($canonical_url = '') } } - public function getCanonicalUrl() + public function getCanonicalUrl(): string { $product = $this->context->smarty->getTemplateVars('product'); From b79d32345ab468dccb0aa5f535ac9543c2c22300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Fernandez?= <50865159+micka-fdz@users.noreply.github.com> Date: Fri, 13 Nov 2020 10:59:19 +0100 Subject: [PATCH 3/6] Update controllers/front/ProductController.php Co-authored-by: GoT --- controllers/front/ProductController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 9f5d09bbad49d..924652005b132 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -86,6 +86,9 @@ public function canonicalRedirection($canonical_url = '') public function getCanonicalUrl(): string { $product = $this->context->smarty->getTemplateVars('product'); + if (!($product instanceof Product)) { + return; + } return $product->getCanonicalUrl(); } From 66cf027ef5b9948c35b28c2a9e3ddce75806cd40 Mon Sep 17 00:00:00 2001 From: mickael Date: Wed, 18 Nov 2020 18:02:30 +0100 Subject: [PATCH 4/6] Fix bad return value type --- controllers/front/ProductController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 924652005b132..298901fef0ffd 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -86,8 +86,9 @@ public function canonicalRedirection($canonical_url = '') public function getCanonicalUrl(): string { $product = $this->context->smarty->getTemplateVars('product'); + if (!($product instanceof Product)) { - return; + return ''; } return $product->getCanonicalUrl(); From c5606039779ebbda5193922793a3b849ffdcac9a Mon Sep 17 00:00:00 2001 From: mickael Date: Thu, 19 Nov 2020 10:11:00 +0100 Subject: [PATCH 5/6] Format with php-cs-fixer --- controllers/front/ProductController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 298901fef0ffd..57974208ddfbe 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -86,7 +86,7 @@ public function canonicalRedirection($canonical_url = '') public function getCanonicalUrl(): string { $product = $this->context->smarty->getTemplateVars('product'); - + if (!($product instanceof Product)) { return ''; } From e4bfc327fb1c34360f156d6e0180c55b234a04dd Mon Sep 17 00:00:00 2001 From: Pierre RAMBAUD Date: Fri, 11 Dec 2020 15:56:29 +0100 Subject: [PATCH 6/6] Make sure the type is ProductLazyArray --- controllers/front/ProductController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 57974208ddfbe..122fa75850dd0 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -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; @@ -83,11 +84,11 @@ public function canonicalRedirection($canonical_url = '') } } - public function getCanonicalUrl(): string + public function getCanonicalURL(): string { $product = $this->context->smarty->getTemplateVars('product'); - if (!($product instanceof Product)) { + if (!($product instanceof ProductLazyArray)) { return ''; }