Skip to content

Commit cf79f59

Browse files
author
Yurii Torbyk
committed
MAGETWO-33450: [GITHUB] When accessing any category - error report generated #899
1 parent 0b22d74 commit cf79f59

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

app/code/Magento/Catalog/Block/Category/View.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ protected function _prepareLayout()
7676
if ($this->_categoryHelper->canUseCanonicalTag()) {
7777
$this->pageConfig->addRemotePageAsset(
7878
$category->getUrl(),
79+
'canonical',
7980
['attributes' => ['rel' => 'canonical']]
8081
);
8182
}

app/code/Magento/Catalog/Block/Product/View.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ protected function _prepareLayout()
148148
if ($this->_productHelper->canUseCanonicalTag()) {
149149
$this->pageConfig->addRemotePageAsset(
150150
$product->getUrlModel()->getUrl($product, ['_ignore_category' => true]),
151+
'canonical',
151152
['attributes' => ['rel' => 'canonical']]
152153
);
153154
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Controller\Product;
7+
8+
/**
9+
* @magentoDataFixture Magento/Catalog/controllers/_files/products.php
10+
*/
11+
class ViewTest extends \Magento\TestFramework\TestCase\AbstractController
12+
{
13+
/**
14+
* @magentoConfigFixture current_store catalog/seo/product_canonical_tag 1
15+
*/
16+
public function testViewActionWithCanonicalTag()
17+
{
18+
$this->dispatch('catalog/product/view/id/1/');
19+
20+
$this->assertContains(
21+
'<link rel="canonical" href="http://localhost/index.php/catalog/product/view/_ignore_category/1/id/1/" />',
22+
$this->getResponse()->getBody()
23+
);
24+
}
25+
}

0 commit comments

Comments
 (0)