Skip to content

Instantly share code, notes, and snippets.

@stefpe
Last active August 25, 2020 20:24
Show Gist options
  • Save stefpe/a33c1eda38b2d0067a9d0039779120b0 to your computer and use it in GitHub Desktop.
Save stefpe/a33c1eda38b2d0067a9d0039779120b0 to your computer and use it in GitHub Desktop.
private function feedData(): void
{
$productFile = new \SplFileObject($this->productFilePath);
$productFile->fgetcsv();//ignore headline
while ($data = $productFile->fgetcsv()) {
list($rowIdx, $title, $price, $retailer, $rating, $desc) = $data;
$doc = array_merge(
$this->indexDefinition,
[
'id' => $rowIdx,
'body' => [
'title' => $title,
'price' => (float)$price,
'retailer' => $retailer,
'rating' => (float)$rating,
'desc' => $desc
]
]
);
$this->client->index($doc);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment