Reduce redundant data when importing daytrips
This commit is contained in:
@@ -88,6 +88,13 @@ class DateImportService implements SingletonInterface
|
|||||||
*/
|
*/
|
||||||
protected $cacheService;
|
protected $cacheService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
static protected $cache = [
|
||||||
|
'datesAdded' => [],
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ConfigurationManagerInterface $configurationManager
|
* @param ConfigurationManagerInterface $configurationManager
|
||||||
* @param CacheService $cacheService
|
* @param CacheService $cacheService
|
||||||
@@ -272,7 +279,16 @@ class DateImportService implements SingletonInterface
|
|||||||
$dateCount = 0;
|
$dateCount = 0;
|
||||||
foreach ($xmlDate->hotel as $xmlHotel)
|
foreach ($xmlDate->hotel as $xmlHotel)
|
||||||
{
|
{
|
||||||
|
$hotelCode = (string) $xmlHotel->attributes()['code'];
|
||||||
$date = $this->createDateRecord($product, $xmlDate);
|
$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) {
|
if ($this->parseHotel($xmlHotel, $date) !== false) {
|
||||||
$this->db->insert(
|
$this->db->insert(
|
||||||
'tx_epproducts_domain_model_date_temp',
|
'tx_epproducts_domain_model_date_temp',
|
||||||
@@ -286,6 +302,8 @@ class DateImportService implements SingletonInterface
|
|||||||
);
|
);
|
||||||
$dateCount++;
|
$dateCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static::$cache['datesAdded'][] = $key;
|
||||||
}
|
}
|
||||||
$this->db->update(
|
$this->db->update(
|
||||||
'tx_epproducts_domain_model_product',
|
'tx_epproducts_domain_model_product',
|
||||||
|
|||||||
Reference in New Issue
Block a user