wilr / silverstripe-algolia

Handles indexing Silverstripe Pages into Algolia and providing results
BSD 3-Clause "New" or "Revised" License
13 stars 16 forks source link

add arbitrary data #32

Closed teundirectlease closed 4 years ago

teundirectlease commented 4 years ago

Currently their is no option to add arbitrary data?

It would be nice to have a function that expands the json object for example i wan't to add a boolean field to the root of the algolia object.

matt-in-a-hat commented 4 years ago

You can use this on classes that are being indexed, e.g. in Page.php

/**
 * @var SilverStripe\ORM\Map $attributes
 */
public function updateAlgoliaAttributes(&$attributes)
{
    $attributes->push('objectCustomThing', $this->MyCustomThingField);
}
teundirectlease commented 4 years ago

Thanks @matt-in-a-hat, works like a charm!