public function execute($data) { $this->_loadModels(); $resource = $this->Resource->findById($data['resource_id']); if (!$resource) { return false; } # Populate collections $cids = $this->Resource->Membership->memberships($data['resource_id']); $resource['Collection'] = $this->Collection->find('list', array('fields' => 'Collection.title', 'conditions' => array('Collection.id' => $cids))); $indexer = new \Arcs\SolrIndexer(); $indexer->addResource($resource); }
public function index_all() { $indexer = new \Arcs\SolrIndexer(); $offset = 0; while (true) { $resources = $this->Resource->find('all', array('limit' => 50, 'offset' => $offset)); if (!$resources) { break; } foreach ($resources as $r) { $id = $r['Resource']['id']; $cids = $this->Resource->Membership->memberships($id); $r['Collection'] = $this->Collection->find('list', array('fields' => 'Collection.title', 'conditions' => array('Collection.id' => $cids))); $this->out("INDEX {$id}"); $indexer->addResource($r); } $offset += 50; } }