Last active
August 25, 2020 20:24
-
-
Save stefpe/a33c1eda38b2d0067a9d0039779120b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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