@@ -282,6 +282,21 @@ protected function appendWithSwatchOptions(
282
282
}
283
283
}
284
284
285
+ protected function isAttributeSkipped (
286
+ Attribute $ attribute ,
287
+ bool $ isSingleProduct
288
+ ): bool {
289
+ if ($ isSingleProduct ) {
290
+ return !$ attribute ->getIsVisibleOnFront (); // skip attribute if is is not visible on FE
291
+ }
292
+
293
+ /**
294
+ * On PLP, KEEP attribute if it is used on PLP and is visible on FE.
295
+ * This means if not visible on PLP or is not visible we should SKIP it.
296
+ */
297
+ return !$ attribute ->getUsedInProductListing () || !$ attribute ->getIsVisibleOnFront ();
298
+ }
299
+
285
300
/**
286
301
* @inheritDoc
287
302
* @throws LocalizedException
@@ -297,6 +312,8 @@ public function process(
297
312
$ attributes = [];
298
313
$ swatchAttributes = [];
299
314
315
+ $ isSingleProduct = isset ($ processorOptions ['isSingleProduct ' ]) ? $ processorOptions ['isSingleProduct ' ] : false ;
316
+
300
317
$ fields = $ this ->getFieldsFromProductInfo (
301
318
$ graphqlResolveInfo ,
302
319
$ graphqlResolvePath
@@ -321,7 +338,7 @@ public function process(
321
338
* @var Attribute $attribute
322
339
*/
323
340
foreach ($ product ->getAttributes () as $ attributeCode => $ attribute ) {
324
- if (! $ attribute -> getIsVisibleOnFront ( )) {
341
+ if ($ this -> isAttributeSkipped ( $ attribute , $ isSingleProduct )) {
325
342
continue ;
326
343
}
327
344
@@ -338,7 +355,6 @@ public function process(
338
355
$ attributes [$ attributeCode ] = $ attribute ;
339
356
340
357
// Collect all swatches (we will need additional data for them)
341
- /** @var Attribute $attribute */
342
358
if ($ isCollectOptions && $ this ->swatchHelper ->isSwatchAttribute ($ attribute )) {
343
359
$ swatchAttributes [] = $ attributeCode ;
344
360
}
0 commit comments