Skip to content

Commit c2a1f25

Browse files
Sergii Kovalenkodanielrenaud
authored andcommitted
MAGETWO-91608: SEO-friendly URL for category page not working
1 parent 943e2cd commit c2a1f25

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Category.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Controller\Adminhtml;
79

10+
use Magento\Store\Model\Store;
11+
812
/**
913
* Catalog category controller
1014
*/
@@ -34,6 +38,22 @@ public function __construct(
3438
parent::__construct($context);
3539
}
3640

41+
/**
42+
* Resolve store id
43+
*
44+
* Tries to take store id from store HTTP parameter, if can`t find it, try to dig into store_id
45+
* If param is absent in store_id too, take default one
46+
* @see Store
47+
*
48+
* @return int
49+
*/
50+
private function resolveStoreId() : int
51+
{
52+
$storeId = $this->getRequest()->getParam('store', false);
53+
$storeId = $storeId === false ? $this->getRequest()->getParam('store_id', Store::DEFAULT_STORE_ID) : $storeId;
54+
return (int) $storeId;
55+
}
56+
3757
/**
3858
* Initialize requested category and put it into registry.
3959
* Root category can be returned, if inappropriate store/category is specified
@@ -44,7 +64,7 @@ public function __construct(
4464
protected function _initCategory($getRootInstead = false)
4565
{
4666
$categoryId = $this->resolveCategoryId();
47-
$storeId = (int)$this->getRequest()->getParam('store');
67+
$storeId = $this->resolveStoreId();
4868
$category = $this->_objectManager->create(\Magento\Catalog\Model\Category::class);
4969
$category->setStoreId($storeId);
5070

0 commit comments

Comments
 (0)