Hello.
I've just followed the tutorial for site search and I am getting some strange results from the search.
The strange thing is that the results I get back don't act as if they're the class they're supposed to be.
For example, I have a ProductPage that extends Page which, among other things, contains an Image through a has_one.
When I do a search on one of the products I get a DataObjectSet back with a ProductPage DataObject and as far as I can see, all the data for the page is correct. However if I do an attempt to get the image I get an empty image object, not the image related to the product.
I found a way around this by looping through the search results and doing
$results = $form->getResults();
$searchData = new DataObjectSet;
foreach ($results as $result) {
$searchData->push(DataObject::get_by_id($result->ClassName, (int)$result->ID));
}
$data['Results'] = $searchData;
And then returning $searchData to the template. Now I get access to the correct images and stuff. However this is essentially fetching the same results twice so if there's an easier way to make the search function return the right stuff I would be very happy if someone could tell me what to do.
Kindly, Marcus.