Avoid redundant database records
This commit is contained in:
@@ -298,11 +298,18 @@ class DateImportService implements SingletonInterface
|
|||||||
*/
|
*/
|
||||||
protected function parseDaytripDates(\SimpleXMLElement $xmlDate, array $product)
|
protected function parseDaytripDates(\SimpleXMLElement $xmlDate, array $product)
|
||||||
{
|
{
|
||||||
|
static $datesAdded = [];
|
||||||
|
|
||||||
foreach ($xmlDate->hotel as $xmlHotel)
|
foreach ($xmlDate->hotel as $xmlHotel)
|
||||||
{
|
{
|
||||||
$hotelCode = (string) $xmlHotel->attributes()['code'];
|
$hotelCode = (string) $xmlHotel->attributes()['code'];
|
||||||
$hotel = $this->hotelMappings[$hotelCode];
|
|
||||||
$dateStart = \DateTime::createFromFormat('d.m.Y', (string) $xmlDate->attributes()['termin'])->format('Y-m-d');
|
$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(
|
$this->db->insert(
|
||||||
'tx_epproducts_domain_model_daytrip_temp',
|
'tx_epproducts_domain_model_daytrip_temp',
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user