Skip to content

Instantly share code, notes, and snippets.

@spinegar
Created August 19, 2014 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spinegar/ce52c041fc4aab5c2508 to your computer and use it in GitHub Desktop.
Save spinegar/ce52c041fc4aab5c2508 to your computer and use it in GitHub Desktop.
A script to index ElasticSearch after performing Sugar database work.
<?php
require('vendor/autoload.php');
$sugar = new \Spinegar\Sugar7Wrapper\Rest();
$sugar->setUrl('https://sugar/rest/v10/')
->setUsername('admin')
->setPassword('secretpassword')
->connect();
$modules = ['Accounts', 'Opportunities', 'Cases', 'Leads', 'Contacts', 'Bugs', 'Products', 'Notes', 'Calls', 'Meetings', 'Manufacturers', 'Products', 'ProductCategories', 'RevenueLineItems', 'Documents', 'Emails', 'Reports', 'Manufacturers'];
foreach($modules as $module)
{
echo "Indexing " . $module . "... ";
$records = $sugar->search($module);
foreach($records['records'] as $record)
{
$sugar->update($module, $record['id'], []);
}
echo "Done. <br /><br />";
}
echo "Indexing Complete!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment