Skip to content

Commit

Permalink
MAGETWO-33450: [GITHUB] When accessing any category - error report ge…
Browse files Browse the repository at this point in the history
…nerated #899
  • Loading branch information
Yurii Torbyk committed Feb 10, 2015
1 parent 0b22d74 commit cf79f59
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/Block/Category/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected function _prepareLayout()
if ($this->_categoryHelper->canUseCanonicalTag()) {
$this->pageConfig->addRemotePageAsset(
$category->getUrl(),
'canonical',
['attributes' => ['rel' => 'canonical']]
);
}
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/Block/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ protected function _prepareLayout()
if ($this->_productHelper->canUseCanonicalTag()) {
$this->pageConfig->addRemotePageAsset(
$product->getUrlModel()->getUrl($product, ['_ignore_category' => true]),
'canonical',
['attributes' => ['rel' => 'canonical']]
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Controller\Product;

/**
* @magentoDataFixture Magento/Catalog/controllers/_files/products.php
*/
class ViewTest extends \Magento\TestFramework\TestCase\AbstractController
{
/**
* @magentoConfigFixture current_store catalog/seo/product_canonical_tag 1
*/
public function testViewActionWithCanonicalTag()
{
$this->dispatch('catalog/product/view/id/1/');

$this->assertContains(
'<link rel="canonical" href="http://localhost/index.php/catalog/product/view/_ignore_category/1/id/1/" />',
$this->getResponse()->getBody()
);
}
}

0 comments on commit cf79f59

Please sign in to comment.