Skip unavailable hotels in Google export
This commit is contained in:
+12
-8
@@ -23,23 +23,27 @@ class GoogleBusinessFeedCsvFormatter
|
||||
|
||||
foreach ($data['product'] as $product) {
|
||||
$minPrice = 0;
|
||||
$available = 0;
|
||||
|
||||
foreach ($product['hotels']['hotel'] as $hotel) {
|
||||
foreach ($hotel['dates']['date'] as $date) {
|
||||
if ($minPrice === 0 || $date['minprice'] < $minPrice) {
|
||||
$minPrice = $date['minprice'];
|
||||
}
|
||||
$available++;
|
||||
}
|
||||
}
|
||||
|
||||
$csv[] = [
|
||||
$product['@id'],
|
||||
$product['@id'],
|
||||
$product['name'],
|
||||
$product['link'],
|
||||
$product['images']['image'][0],
|
||||
$minPrice . '.00 EUR',
|
||||
];
|
||||
if ($available > 0) {
|
||||
$csv[] = [
|
||||
$product['@id'],
|
||||
$product['@id'],
|
||||
$product['name'],
|
||||
$product['link'],
|
||||
$product['images']['image'][0],
|
||||
$minPrice . '.00 EUR',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $csv;
|
||||
|
||||
Reference in New Issue
Block a user