I'm trying to index a custom entity in Solr with Magento. I've followed this guide: http://www.summasolutions.net/blogposts/magento-apache-solr-integration-part-iii-indexing-custom-data, but I still can't make it work.
In my case I have an EAV entity that represents a news and I want the default Magento search showing results including this entity.
Similar to the guide I've created the "getSolrDocument" function:
protected function getNewsSolrDocument($id, $name, $storeId, $visibility, $category, $title, $subtitle, $description) {
$document = new Apache_Solr_Document();
$document->addField("id", $id);
$document->addField("unique", $id);
$document->addField("news_name_en", $name);
$document->addField("news_category_en", $category);
$document->addField("news_title_en", $title);
$document->addField("news_subtitle_en", $subtitle);
$document->addField("news_description_en", $description);
return $document;
}
And a "addSolrDocument":
protected function addSolrDocument(&$solrClient, $document) {
$solrClient->addDocument($document);
$solrClient->commit();
}
But $solrClient->addDocument($document) throws an exception:
"400" Status: [doc=15] missing required field: visibility
I've noticed that in the Solr schema provided by Magento there is this part:
<!-- System required fields. -->
<field name="id" type="string" indexed="true" required="true" stored="true"/>
<field name="unique" type="string" indexed="true" required="true"/>
<field name="store_id" type="int" indexed="true" required="true"/>
<field name="in_stock" type="boolean" indexed="true" required="true"/>
<field name="visibility" type="int" indexed="true" required="true"/>
The part defines which fields are mandatory but for my news entity "in_stock" and "visibility" are useless.
I'm using Magento EE 1.14.0.1 and Solr 3.6.2. What's the proper way to achive my goal? Thanks