Reduce redundant data when importing daytrips

This commit is contained in:
Björn Fromme
2018-10-02 18:38:37 +02:00
parent 731bfe13cc
commit f66a51b911
@@ -88,6 +88,13 @@ class DateImportService implements SingletonInterface
*/
protected $cacheService;
/**
* @var array
*/
static protected $cache = [
'datesAdded' => [],
];
/**
* @param ConfigurationManagerInterface $configurationManager
* @param CacheService $cacheService
@@ -272,7 +279,16 @@ class DateImportService implements SingletonInterface
$dateCount = 0;
foreach ($xmlDate->hotel as $xmlHotel)
{
$hotelCode = (string) $xmlHotel->attributes()['code'];
$date = $this->createDateRecord($product, $xmlDate);
$key = $hotelCode . $date['date_start'];
// Import daytrip dates only once per hotel as room information is taken
// from contingents
if ($product['daytrip'] && \in_array($key, static::$cache['datesAdded'], true)) {
continue;
}
if ($this->parseHotel($xmlHotel, $date) !== false) {
$this->db->insert(
'tx_epproducts_domain_model_date_temp',
@@ -286,6 +302,8 @@ class DateImportService implements SingletonInterface
);
$dateCount++;
}
static::$cache['datesAdded'][] = $key;
}
$this->db->update(
'tx_epproducts_domain_model_product',