Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/code/Magento/Catalog/Controller/Category/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ protected function _initCategory()
* Category view action
*
* @throws NoSuchEntityException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function execute()
{
Expand Down Expand Up @@ -251,6 +252,10 @@ public function execute()
if ($this->shouldRedirectOnToolbarAction()) {
$this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
}

if ($this->shouldNoIndexNoFollow()) {
$page->getConfig()->setRobots('NOINDEX,NOFOLLOW');
}
return $page;
} elseif (!$this->getResponse()->isRedirect()) {
$result = $this->resultForwardFactory->create()->forward('noroute');
Expand Down Expand Up @@ -315,4 +320,20 @@ private function shouldRedirectOnToolbarAction(): bool
Toolbar::LIMIT_PARAM_NAME
], array_keys($params))) === false;
}

/**
* Checks for robots meta tags
*
* @return bool
*/
private function shouldNoIndexNoFollow(): bool
{
$params = $this->getRequest()->getParams();

return empty(array_diff(array_keys($params), [
Toolbar::LIMIT_PARAM_NAME,
Toolbar::PAGE_PARM_NAME,
'id'
])) === false;
}
}