File tree 1 file changed +14
-4
lines changed
src/Model/Resolver/Products/DataPostProcessor
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -289,16 +289,25 @@ protected function appendWithSwatchOptions(
289
289
290
290
protected function isAttributeSkipped (
291
291
Attribute $ attribute ,
292
- bool $ isSingleProduct
292
+ bool $ isSingleProduct ,
293
+ bool $ isCompare
293
294
): bool {
294
295
/**
295
296
* On PLP, KEEP attribute if it is used on PLP.
296
297
* This means if not visible on PLP we should SKIP it.
297
- *
298
+ *
298
299
* On PDP, If attribute has no label then it shouldn't be
299
300
* visible.
301
+ *
302
+ * Don't skip if attribute is for the compare page
300
303
*/
301
- return !$ attribute ->getUsedInProductListing () || !$ attribute ->getStoreLabel ();
304
+ $ result = !$ attribute ->getUsedInProductListing () || !$ attribute ->getStoreLabel ();
305
+
306
+ if ($ isCompare ) {
307
+ $ result = !$ attribute ->getIsComparable () || !$ attribute ->getIsVisible ();
308
+ }
309
+
310
+ return $ result ;
302
311
}
303
312
304
313
/**
@@ -317,6 +326,7 @@ public function process(
317
326
$ swatchAttributes = [];
318
327
319
328
$ isSingleProduct = isset ($ processorOptions ['isSingleProduct ' ]) ? $ processorOptions ['isSingleProduct ' ] : false ;
329
+ $ isCompare = isset ($ processorOptions ['isCompare ' ]) ? $ processorOptions ['isCompare ' ] : false ;
320
330
321
331
$ fields = $ this ->getFieldsFromProductInfo (
322
332
$ graphqlResolveInfo ,
@@ -342,7 +352,7 @@ public function process(
342
352
* @var Attribute $attribute
343
353
*/
344
354
foreach ($ product ->getAttributes () as $ attributeCode => $ attribute ) {
345
- if ($ this ->isAttributeSkipped ($ attribute , $ isSingleProduct )) {
355
+ if ($ this ->isAttributeSkipped ($ attribute , $ isSingleProduct, $ isCompare )) {
346
356
continue ;
347
357
}
348
358
You can’t perform that action at this time.
0 commit comments