Skip to content

Commit 4cdb0ac

Browse files
Merge pull request #12 from zans-laksa/1410-compare-page
Compage Page Backend
2 parents b02c6d7 + 7cd51a0 commit 4cdb0ac

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Model/Resolver/Products/DataPostProcessor/Attributes.php

+14-4
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,25 @@ protected function appendWithSwatchOptions(
289289

290290
protected function isAttributeSkipped(
291291
Attribute $attribute,
292-
bool $isSingleProduct
292+
bool $isSingleProduct,
293+
bool $isCompare
293294
): bool {
294295
/**
295296
* On PLP, KEEP attribute if it is used on PLP.
296297
* This means if not visible on PLP we should SKIP it.
297-
*
298+
*
298299
* On PDP, If attribute has no label then it shouldn't be
299300
* visible.
301+
*
302+
* Don't skip if attribute is for the compare page
300303
*/
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;
302311
}
303312

304313
/**
@@ -317,6 +326,7 @@ public function process(
317326
$swatchAttributes = [];
318327

319328
$isSingleProduct = isset($processorOptions['isSingleProduct']) ? $processorOptions['isSingleProduct'] : false;
329+
$isCompare = isset($processorOptions['isCompare']) ? $processorOptions['isCompare'] : false;
320330

321331
$fields = $this->getFieldsFromProductInfo(
322332
$graphqlResolveInfo,
@@ -342,7 +352,7 @@ public function process(
342352
* @var Attribute $attribute
343353
*/
344354
foreach ($product->getAttributes() as $attributeCode => $attribute) {
345-
if ($this->isAttributeSkipped($attribute, $isSingleProduct)) {
355+
if ($this->isAttributeSkipped($attribute, $isSingleProduct, $isCompare)) {
346356
continue;
347357
}
348358

0 commit comments

Comments
 (0)