Avoid redundant database records

This commit is contained in:
Björn Fromme
2018-09-28 12:41:04 +02:00
parent 24adcaebd2
commit 88cd338cbe
@@ -298,11 +298,18 @@ class DateImportService implements SingletonInterface
*/
protected function parseDaytripDates(\SimpleXMLElement $xmlDate, array $product)
{
static $datesAdded = [];
foreach ($xmlDate->hotel as $xmlHotel)
{
$hotelCode = (string) $xmlHotel->attributes()['code'];
$hotel = $this->hotelMappings[$hotelCode];
$dateStart = \DateTime::createFromFormat('d.m.Y', (string) $xmlDate->attributes()['termin'])->format('Y-m-d');
$key = $hotelCode . $dateStart;
if (\in_array($key, $datesAdded, true)) {
continue;
}
$datesAdded[] = $key;
$hotel = $this->hotelMappings[$hotelCode];
$this->db->insert(
'tx_epproducts_domain_model_daytrip_temp',
[