Skip to content

Commit

Permalink
Merge pull request #34 from shopware/next-37781/fix-quotes-from-scripts
Browse files Browse the repository at this point in the history
Next 37781 - Fix quotes from scripts + prepare v0.8.0
  • Loading branch information
MalteJanz authored Aug 20, 2024
2 parents 9bec912 + 14913c7 commit b44da1d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# NEXT-RELEASE
- NEXT-37516 - Added `sync` command argument `-t` `--try-count` which configures the maximum number of tries before a failed but processable request is dropped for the `import` mode

# v0.8.0

- NEXT-37303 - [BREAKING] changed `sync` command argument `-s` `--schema` to `-p` `--profile`
- NEXT-37303 - [BREAKING] Fixed an issue where `row` values were always provided as strings in the deserialize script.
Now they are converted into their proper types before passed to the script.
Expand All @@ -10,7 +12,9 @@ Now they are converted into their proper types before passed to the script.
- NEXT-37317 - Added various default profiles
- NEXT-37318 - Added `copy-profile` command, to copy the default profiles to your system
- NEXT-37504 - Fixed the generation of request criteria to support correct nested associations
- NEXT-37516 - Added `sync` command argument `-t` `--try-count` which configures the maximum number of tries before a failed but processable request is dropped for the `import` mode
- NEXT-37602 - Added `get_currency_by_iso(isoCode)` function to scripting, which allows to lookup currency IDs in the shop based on their iso code. A lookup table is generated at startup, thus calling this function should not cause excessive slowdowns.
- NEXT-37781 - Fixed string values set by script containing double quotes

# v0.7.1

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sw-sync-cli"
version = "0.7.1"
version = "0.8.0"
edition = "2021"
description = "CLI for fast and flexible data transfer between shopware and (CSV) files over API"
keywords = ["cli", "shopware", "import", "export"]
Expand Down
19 changes: 2 additions & 17 deletions profiles/default_product.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ mappings:
entity_path: "taxId"
- file_column: "manufacturer id"
entity_path: "manufacturer?.id"
- file_column: "default manufacturer name"
entity_path: "manufacturer?.name"
- file_column: "media id"
entity_path: "media"
- file_column: "cover id"
Expand Down Expand Up @@ -45,18 +47,12 @@ mappings:
entity_path: "description"
- file_column: "prices"
key: "prices"
- file_column: "default manufacturer name"
key: "default_manufacturer_name"
- file_column: "default price net"
key: "default_price_net"
- file_column: "default price gross"
key: "default_price_gross"

serialize_script: |
row = #{
default_manufacturer_name: entity.manufacturer?.translated?.name
};
if entity.price == () {
row.default_price_net = "";
row.default_price_gross = "";
Expand All @@ -74,8 +70,6 @@ serialize_script: |
}
deserialize_script: |
let default_language = get_default("LANGUAGE_SYSTEM");
entity = #{
prices: row.prices,
price: [#{
Expand All @@ -85,12 +79,3 @@ deserialize_script: |
currencyId: get_default("CURRENCY")
}]
};
if row.default_manufacturer_name != () {
entity.manufacturer = #{
translations: [#{
languageId: default_language,
name: row.default_manufacturer_name
}]
};
}
8 changes: 7 additions & 1 deletion src/data/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ pub fn serialize_entity(
script_mapping.key
)
})?;
let value_str = serde_json::to_string(value)?;

let value_str = if value.is_string() {
// workaround: we don't need "json string" quotes here, so we use the inner string value directly
value.to_string()
} else {
serde_json::to_string(value)?
};

row.push(value_str);
}
Expand Down

0 comments on commit b44da1d

Please sign in to comment.