<?php
$groupedAttributes = [];
foreach ($product->attributeValues as $attributeValue) {
if (!isset($groupedAttributes[$attributeValue->attribute->name])) {
$groupedAttributes[$attributeValue->attribute->name] = [
'name' => $attributeValue->attribute->name,
'values'=> [$attributeValue->value]
];
continue;
}
$groupedAttributes[$attributeValue->attribute->name]['values'][] = $attributeValue->value;
}
foreach($product as $product) {
forearch($product->attributeValues as $attributeValue) {
echo "Название атрибута: {$attributeValue->attribute->name}";
echo "Значение атрибута: {$attributeValue->value}";
}
}