6
6
namespace Magento \Sitemap \Model \ResourceModel \Catalog ;
7
7
8
8
use Magento \CatalogUrlRewrite \Model \CategoryUrlRewriteGenerator ;
9
+ use Magento \Framework \DB \Select ;
9
10
10
11
/**
11
12
* Sitemap resource catalog collection model
@@ -18,7 +19,7 @@ class Category extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
18
19
/**
19
20
* Collection Zend Db select
20
21
*
21
- * @var \Magento\Framework\DB\ Select
22
+ * @var Select
22
23
*/
23
24
protected $ _select ;
24
25
@@ -66,6 +67,8 @@ public function __construct(
66
67
}
67
68
68
69
/**
70
+ * Initialize catalog category entity resource model
71
+ *
69
72
* @return void
70
73
*/
71
74
protected function _construct ()
@@ -120,7 +123,7 @@ public function getCollection($storeId)
120
123
121
124
$ this ->_addFilter ($ storeId , 'is_active ' , 1 );
122
125
123
- $ query = $ connection ->query ($ this ->_select );
126
+ $ query = $ connection ->query ($ this ->prepareSelectStatement ( $ this -> _select ) );
124
127
while ($ row = $ query ->fetch ()) {
125
128
$ category = $ this ->_prepareCategory ($ row );
126
129
$ categories [$ category ->getId ()] = $ category ;
@@ -129,6 +132,17 @@ public function getCollection($storeId)
129
132
return $ categories ;
130
133
}
131
134
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
+
132
146
/**
133
147
* Prepare category
134
148
*
@@ -153,14 +167,14 @@ protected function _prepareCategory(array $categoryRow)
153
167
* @param string $attributeCode
154
168
* @param mixed $value
155
169
* @param string $type
156
- * @return \Magento\Framework\DB\ Select|bool
170
+ * @return Select|bool
157
171
*/
158
172
protected function _addFilter ($ storeId , $ attributeCode , $ value , $ type = '= ' )
159
173
{
160
174
$ meta = $ this ->metadataPool ->getMetadata (\Magento \Catalog \Api \Data \CategoryInterface::class);
161
175
$ linkField = $ meta ->getLinkField ();
162
176
163
- if (!$ this ->_select instanceof \ Magento \ Framework \ DB \ Select) {
177
+ if (!$ this ->_select instanceof Select) {
164
178
return false ;
165
179
}
166
180
@@ -186,7 +200,6 @@ protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
186
200
break ;
187
201
default :
188
202
return false ;
189
- break ;
190
203
}
191
204
192
205
if ($ attribute ['backend_type ' ] == 'static ' ) {
0 commit comments