What is the listing attributes pipeline?
The listing attributes pipeline is used to build the attributes for the Aero\Search\Elastic\Models\Listing model.
It can be extended to add new attributes or modify existing attributes.
For example you can modify the listing's name to include the attributes when the listing is split by them.
\Aero\Search\Elastic\Pipelines\ListingAttributes::extend(function (array $attributes, \Closure $next) {
$splitAttributeGroups = collect($attributes['attribute_groups'] ?? [])
->filter(function ($attributeGroup) {
return $attributeGroup['split'] ?? false;
});
if ($splitAttributeGroups->isEmpty()) {
return $next($attributes);
}
$attributeNames = $splitAttributeGroups->flatMap(function (array $attributeGroup) {
return collect($attributeGroup['attributes'] ?? [])->pluck('name');
});
$attributes['name'] = "{$attributeNames->implode(' ')} {$attributes['name']}";
return $next($attributes);
});
This means if you have a product split by a Colour attribute group, each listing would now be named {colour} {name}, e.g. Red Puffer Jack.
Parameters
| Parameter | Type | Description |
$attributes |
array |
The attributes for the listing model. |
$next |
\Closure |
The next step in the pipeline. |