11
11
12
12
use Magento \Catalog \Api \Data \ProductInterface ;
13
13
use Magento \Catalog \Model \ProductCategoryList ;
14
+ use Magento \Store \Model \Store ;
14
15
15
16
/**
16
17
* Class Product
@@ -164,6 +165,8 @@ public function addToCollection($collection)
164
165
}
165
166
166
167
/**
168
+ * Adds Attributes that belong to Global Scope
169
+ *
167
170
* @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute
168
171
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
169
172
* @return $this
@@ -200,6 +203,8 @@ protected function addGlobalAttribute(
200
203
}
201
204
202
205
/**
206
+ * Adds Attributes that don't belong to Global Scope
207
+ *
203
208
* @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute
204
209
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
205
210
* @return $this
@@ -208,7 +213,7 @@ protected function addNotGlobalAttribute(
208
213
\Magento \Catalog \Model \ResourceModel \Eav \Attribute $ attribute ,
209
214
\Magento \Catalog \Model \ResourceModel \Product \Collection $ collection
210
215
) {
211
- $ storeId = $ this ->storeManager ->getStore ()->getId ();
216
+ $ storeId = $ this ->storeManager ->getStore ()->getId ();
212
217
$ values = $ collection ->getAllAttributeValues ($ attribute );
213
218
$ validEntities = [];
214
219
if ($ values ) {
@@ -218,7 +223,10 @@ protected function addNotGlobalAttribute(
218
223
$ validEntities [] = $ entityId ;
219
224
}
220
225
} else {
221
- if ($ this ->validateAttribute ($ storeValues [\Magento \Store \Model \Store::DEFAULT_STORE_ID ])) {
226
+ if (
227
+ isset ($ storeValues [Store::DEFAULT_STORE_ID ]) &&
228
+ $ this ->validateAttribute ($ storeValues [Store::DEFAULT_STORE_ID ])
229
+ ) {
222
230
$ validEntities [] = $ entityId ;
223
231
}
224
232
}
0 commit comments