Skip to content

Commit 858a613

Browse files
committed
ACP2E-2300: allow in sitemap only categories and products from public shared catalog.
1 parent 2b3ad2e commit 858a613

File tree

1 file changed

+18
-5
lines changed
  • app/code/Magento/Sitemap/Model/ResourceModel/Catalog

1 file changed

+18
-5
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Sitemap\Model\ResourceModel\Catalog;
77

88
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
9+
use Magento\Framework\DB\Select;
910

1011
/**
1112
* Sitemap resource catalog collection model
@@ -18,7 +19,7 @@ class Category extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
1819
/**
1920
* Collection Zend Db select
2021
*
21-
* @var \Magento\Framework\DB\Select
22+
* @var Select
2223
*/
2324
protected $_select;
2425

@@ -66,6 +67,8 @@ public function __construct(
6667
}
6768

6869
/**
70+
* Initialize catalog category entity resource model
71+
*
6972
* @return void
7073
*/
7174
protected function _construct()
@@ -120,7 +123,7 @@ public function getCollection($storeId)
120123

121124
$this->_addFilter($storeId, 'is_active', 1);
122125

123-
$query = $connection->query($this->_select);
126+
$query = $connection->query($this->prepareSelectStatement($this->_select));
124127
while ($row = $query->fetch()) {
125128
$category = $this->_prepareCategory($row);
126129
$categories[$category->getId()] = $category;
@@ -129,6 +132,17 @@ public function getCollection($storeId)
129132
return $categories;
130133
}
131134

135+
/**
136+
* Allow to modify select statement with plugins
137+
*
138+
* @param Select $select
139+
* @return Select
140+
*/
141+
public function prepareSelectStatement(Select $select)
142+
{
143+
return $select;
144+
}
145+
132146
/**
133147
* Prepare category
134148
*
@@ -153,14 +167,14 @@ protected function _prepareCategory(array $categoryRow)
153167
* @param string $attributeCode
154168
* @param mixed $value
155169
* @param string $type
156-
* @return \Magento\Framework\DB\Select|bool
170+
* @return Select|bool
157171
*/
158172
protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
159173
{
160174
$meta = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\CategoryInterface::class);
161175
$linkField = $meta->getLinkField();
162176

163-
if (!$this->_select instanceof \Magento\Framework\DB\Select) {
177+
if (!$this->_select instanceof Select) {
164178
return false;
165179
}
166180

@@ -186,7 +200,6 @@ protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
186200
break;
187201
default:
188202
return false;
189-
break;
190203
}
191204

192205
if ($attribute['backend_type'] == 'static') {

0 commit comments

Comments
 (0)