コード例 #1
0
ファイル: Indexer.php プロジェクト: puntik/amanda_api
 private function esProduct($product)
 {
     $price = $this->getPrice($product);
     $images = $this->getImages($product);
     $productCategory = ProductCategory::where('product_id', $product->id)->get();
     $this->parseCategory();
     $category = $this->getCategory($productCategory[0]->category_id);
     logger()->info(sprintf("Found a price for %d: %f", $product->id, $price));
     $texts = $product->texts;
     $description = isset($texts[0]) ? $texts[0]->value : Lipsum::short()->text(3);
     $rating = ["stars" => 4.5, "count" => 23];
     $fixture = ["id" => $product->id, "title" => $product->brand->title . " " . $product->name, "brand" => $product->brand, "code" => str_slug($product->id . " " . $product->brand->title . " " . $product->name), "description" => $description, "category" => $category, "categoryFull" => json_encode($this->categoryCache), "productCode" => "123456", "labels" => $product->labels, "rating" => $rating, "supplier" => ["title" => "Partner 001", "code" => "partner-001"], "price" => ["price" => $price * 1, "priceVat" => $price * 1.2, "currencyCode" => "CZK"], "availability" => ["count" => 12, "code" => "partner_on_store"], "urlKey" => str_slug($product->id . " " . $product->brand->title . " " . $product->name), "url" => $category["road"] . "/" . str_slug($product->id . " " . $product->brand->title . " " . $product->name), "thumbnail" => isset($images[0]) ? $images[0] : [], "params" => [], "attachments" => [], "media" => [], "images" => $images, "alternatives" => []];
     return $fixture;
 }