@@ -126,8 +126,13 @@ protected function appendWithValue(
126
126
foreach ($ attributes as $ attributeCode => $ attribute ) {
127
127
$ attributeValue = $ product ->getData ($ attributeCode );
128
128
129
+ // Remove all empty attributes
129
130
if (!$ attributeValue ) {
130
- // Remove all empty attributes
131
+ // If attribute does not contain both value nor options then we remove it from output
132
+ if (!isset ($ productAttributes [$ productId ][$ attributeCode ]) ||
133
+ !$ productAttributes [$ productId ][$ attributeCode ]['attribute_options ' ]) {
134
+ unset($ productAttributes [$ productId ][$ attributeCode ]);
135
+ }
131
136
continue ;
132
137
}
133
138
@@ -289,8 +294,11 @@ protected function isAttributeSkipped(
289
294
/**
290
295
* On PLP, KEEP attribute if it is used on PLP.
291
296
* This means if not visible on PLP we should SKIP it.
297
+ *
298
+ * On PDP, If attribute has no label then it shouldn't be
299
+ * visible.
292
300
*/
293
- return !$ attribute ->getUsedInProductListing ();
301
+ return !$ attribute ->getUsedInProductListing () || ! $ attribute -> getStoreLabel () ;
294
302
}
295
303
296
304
/**
@@ -358,12 +366,6 @@ public function process(
358
366
}
359
367
}
360
368
361
- $ this ->appendWithValue (
362
- $ attributes ,
363
- $ productIds ,
364
- $ productAttributes
365
- );
366
-
367
369
if ($ isCollectOptions ) {
368
370
$ this ->appendWithOptions (
369
371
$ attributes ,
@@ -373,6 +375,12 @@ public function process(
373
375
);
374
376
}
375
377
378
+ $ this ->appendWithValue (
379
+ $ attributes ,
380
+ $ productIds ,
381
+ $ productAttributes
382
+ );
383
+
376
384
return function (&$ productData ) use ($ productAttributes ) {
377
385
if (!isset ($ productData ['entity_id ' ])) {
378
386
return ;
0 commit comments