Skip to content

Commit 02b2ace

Browse files
committed
ACP2E-2300: allow in sitemap only categories and products from public shared catalog based on catalog permissions instead of shared catalog.
1 parent 3ebeb73 commit 02b2ace

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Category.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class Category extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
4848
protected $metadataPool;
4949

5050
/**
51-
* @var ManagerInterface
51+
* @var SelectWrapper
5252
*/
53-
private $eventManager;
53+
private $selectWrapper;
5454

5555
/**
5656
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
@@ -66,13 +66,13 @@ public function __construct(
6666
\Magento\Catalog\Model\ResourceModel\Category $categoryResource,
6767
\Magento\Framework\EntityManager\MetadataPool $metadataPool,
6868
$connectionName = null,
69-
ManagerInterface $eventManager = null
69+
SelectWrapper $selectWrapper = null
7070
) {
7171
$this->_storeManager = $storeManager;
7272
$this->_categoryResource = $categoryResource;
7373
parent::__construct($context, $connectionName);
7474
$this->metadataPool = $metadataPool;
75-
$this->eventManager = $eventManager ?? ObjectManager::getInstance()->get(ManagerInterface::class);
75+
$this->selectWrapper = $selectWrapper ?? ObjectManager::getInstance()->get(SelectWrapper::class);
7676
}
7777

7878
/**
@@ -132,12 +132,9 @@ public function getCollection($storeId)
132132

133133
$this->_addFilter($storeId, 'is_active', 1);
134134

135-
$this->eventManager->dispatch(
136-
'sitemap_category_select_init',
137-
['select' => $this->_select]
135+
$query = $connection->query(
136+
$this->selectWrapper->getSelectStatement($this->_select)
138137
);
139-
140-
$query = $connection->query($this->_select);
141138
while ($row = $query->fetch()) {
142139
$category = $this->_prepareCategory($row);
143140
$categories[$category->getId()] = $category;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright 2023 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
*/
15+
16+
namespace Magento\Sitemap\Model\ResourceModel\Catalog;
17+
18+
use Magento\Framework\DB\Select;
19+
20+
class SelectWrapper
21+
{
22+
/**
23+
* Allow to modify select statement with plugins
24+
*
25+
* @param Select $select
26+
* @return Select
27+
*/
28+
public function getSelectStatement(Select $select)
29+
{
30+
return $select;
31+
}
32+
}

0 commit comments

Comments
 (0)