Created
March 2, 2018 06:14
-
-
Save michaelrog/a4de4246a5facf3582fa6c26cce382c5 to your computer and use it in GitHub Desktop.
Search Plus custom mapping example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyPlugin extends BasePlugin | |
{ | |
// ... | |
public function searchPlus_addAlgoliaMapping() | |
{ | |
return [ | |
[ | |
'name' => 'My Basic Mapping', | |
'handle' => 'my_index', | |
'description' => '...', | |
'method' => 'myPlugin.basicMapping' | |
], | |
]; | |
} | |
// ... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyPluginService extends BaseApplicationComponent | |
{ | |
//... | |
public function basicMapping(BaseElementModel $element) | |
{ | |
$mapping = []; | |
$mapping['objectID'] = $element->id; | |
$mapping['elementId'] = intval($element->id); | |
$mapping['status'] = $element->getStatus(); | |
$mapping['title'] = $element->getStatus(); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment