diff --git a/app/code/Magento/Catalog/Controller/Category/View.php b/app/code/Magento/Catalog/Controller/Category/View.php index 196eb313bc62d..b76f039aca5d2 100644 --- a/app/code/Magento/Catalog/Controller/Category/View.php +++ b/app/code/Magento/Catalog/Controller/Category/View.php @@ -22,7 +22,6 @@ use Magento\Framework\App\ActionInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Controller\Result\ForwardFactory; -use Magento\Framework\Controller\ResultInterface; use Magento\Framework\DataObject; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; @@ -210,6 +209,9 @@ public function execute() return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl()); } $category = $this->_initCategory(); + if ($this->toolbarMemorizer->hasMemorizingParam()) { + return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl()); + } if ($category) { $this->layerResolver->create(Resolver::CATALOG_LAYER_CATEGORY); $settings = $this->_catalogDesign->getDesignSettings($category); diff --git a/app/code/Magento/Catalog/Model/Product/ProductList/ToolbarMemorizer.php b/app/code/Magento/Catalog/Model/Product/ProductList/ToolbarMemorizer.php index 9c1a781d594f7..84bf0b62f239e 100644 --- a/app/code/Magento/Catalog/Model/Product/ProductList/ToolbarMemorizer.php +++ b/app/code/Magento/Catalog/Model/Product/ProductList/ToolbarMemorizer.php @@ -3,7 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); namespace Magento\Catalog\Model\Product\ProductList; @@ -15,13 +14,14 @@ * Class ToolbarMemorizer * * Responds for saving toolbar settings to catalog session + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class ToolbarMemorizer { /** * XML PATH to enable/disable saving toolbar parameters to session */ - const XML_PATH_CATALOG_REMEMBER_PAGINATION = 'catalog/frontend/remember_pagination'; + public const XML_PATH_CATALOG_REMEMBER_PAGINATION = 'catalog/frontend/remember_pagination'; /** * @var CatalogSession @@ -63,6 +63,11 @@ class ToolbarMemorizer */ private $isMemorizingAllowed; + /** + * @var bool + */ + private $hasMemorizeParam = false; + /** * @param Toolbar $toolbarModel * @param CatalogSession $catalogSession @@ -173,7 +178,18 @@ private function memorizeParam($param, $value) { if ($value && $this->catalogSession->getData($param) != $value) { $this->catalogSession->setData($param, $value); + $this->hasMemorizeParam = true; } return $this; } + + /** + * Check has Memorize parameter value apply + * + * @return bool + */ + public function hasMemorizingParam() + { + return $this->hasMemorizeParam; + } }