I have an import using WP ALL-IMPORT where the xml looks like this.
<ROW artnum="53241" klant="-1" week="35" dag="0" jaar="2024" klantgroep="0" advprijs="2.95" artorg="3.2" artbtw="9"/>
<ROW artnum="53241" klant="-1" week="36" dag="0" jaar="2024" klantgroep="0" advprijs="2.95" artorg="3.2" artbtw="9"/>
<ROW artnum="53241" klant="-1" week="37" dag="0" jaar="2024" klantgroep="0" advprijs="2.95" artorg="3.2" artbtw="9"/>
<ROW artnum="54137" klant="-1" week="35" dag="0" jaar="2024" klantgroep="0" advprijs="2.95" artorg="3.1" artbtw="9"/>
<ROW artnum="54137" klant="-1" week="36" dag="0" jaar="2024" klantgroep="0" advprijs="2.95" artorg="3.1" artbtw="9"/>
<ROW artnum="54137" klant="-1" week="37" dag="0" jaar="2024" klantgroep="0" advprijs="2.95" artorg="3.1" artbtw="9"/>
artnum = product_ID
Week is the week the product is on sale
For example week 37 = ‘2024-09-09 to 2024-09-15’
I created a function to get the start date and the end date. it looks like this.
function get_current_year_week_start_date($week) {
// Get the current year
$year = date('Y');
// Create a new DateTime object
$dto = new DateTime();
// Set the DateTime object to the start of the specified week in the current year
$dto->setISODate($year, $week);
// Return the start date of the week
return $dto->format('Y-m-d');
}
So the problem now is that the import for product id 54137 is happening 3 times so it overwrites the data so the sale is only on week 37 and not from 35 to 37.
Is there a way to see in the import wich value is lower? or will it be better to skip already imported product_ids and only import the lowest week number?