diff --git a/src/main.rs b/src/main.rs index 42439b3..8ac5263 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,7 @@ fn main() -> Result<(), csv::Error> { let sales_channel; let id = record.subshop_id.unwrap(); - if id.clone().eq("3") { // Lodner Geschmackswelten + if id.clone().eq("3") && false { // Lodner Geschmackswelten sales_channel = "019774250010707285e7d325962e0089"; if temp_target_url.len() > 2 && temp_target_url[temp_target_url.len() - 2].parse::().ok().is_some() && !record.attr1.clone().unwrap().eq("NULL") { @@ -80,14 +80,48 @@ fn main() -> Result<(), csv::Error> { }) } } - } else if id.clone().eq("1") { // Lodner Gewürze //sales_channel = "0197742500027367a2f45220911057e8"; sales_channel = "019774250010707285e7d325962e0089"; // Set Geschmackswelten ID because, both shops got combined + if temp_target_url.len() > 2 && temp_target_url[temp_target_url.len() - 2].parse::().ok().is_some() && !record.attr1.clone().unwrap().eq("NULL") { + temp_target_url.remove(temp_target_url.len() - 2); // Remove number before product name + + temp_target_url.insert(0, "gewuerze/gewuerze-lodner".to_string()); + + if !record.attr1.clone().unwrap().eq("NULL") { + temp_target_url.push(record.attr1.unwrap()); // Add article number if not null + } + + // Combine to new target url + let target_url = temp_target_url.join("/"); - } else if id.clone().eq("2") { // Pfefferkontor + // Build source url + let mut source_url_vec: Vec = Vec::new(); + source_url_vec.push(record.path); + + // Combine source url + let source_url = source_url_vec.join("/"); + + + if !old_source_url.eq(source_url.clone().as_str()) { + old_source_url = source_url.clone(); + + records.push(Record{ + source_url, + target_url: Some(target_url), + http_code: Some("301".to_string()), + enabled: Some("1".to_string()), + query_params_handling: Some("1".to_string()), // 1 to ignore query parameters + sales_channel_id: Some(sales_channel.to_string()), + }) + } + } + + + + } else if id.clone().eq("2") && false { // Pfefferkontor sales_channel = "01977425000c72f3b2f6015decfed1f4"; if temp_target_url.len() > 2 && temp_target_url[temp_target_url.len() - 2].parse::().ok().is_some() && !record.attr1.clone().unwrap().eq("NULL") {