Skip unavailable hotels in Google export

This commit is contained in:
Björn Fromme
2019-05-07 15:11:55 +02:00
parent 01cd6e099e
commit 1c0025e5bd
@@ -23,15 +23,18 @@ class GoogleBusinessFeedCsvFormatter
foreach ($data['product'] as $product) { foreach ($data['product'] as $product) {
$minPrice = 0; $minPrice = 0;
$available = 0;
foreach ($product['hotels']['hotel'] as $hotel) { foreach ($product['hotels']['hotel'] as $hotel) {
foreach ($hotel['dates']['date'] as $date) { foreach ($hotel['dates']['date'] as $date) {
if ($minPrice === 0 || $date['minprice'] < $minPrice) { if ($minPrice === 0 || $date['minprice'] < $minPrice) {
$minPrice = $date['minprice']; $minPrice = $date['minprice'];
} }
$available++;
} }
} }
if ($available > 0) {
$csv[] = [ $csv[] = [
$product['@id'], $product['@id'],
$product['@id'], $product['@id'],
@@ -41,6 +44,7 @@ class GoogleBusinessFeedCsvFormatter
$minPrice . '.00 EUR', $minPrice . '.00 EUR',
]; ];
} }
}
return $csv; return $csv;
} }