@@ -42,18 +42,20 @@ public class UmbracoCommerceVariantsEditorValueConnector(
42
42
return null ;
43
43
}
44
44
45
- if ( ! jsonSerializer . TryDeserialize ( value , out VariantsBlockEditorValueBase ? storeValue ) || ! storeValue . StoreId . HasValue )
46
- {
47
- return null ;
48
- }
49
-
50
45
if ( ! jsonSerializer . TryDeserialize ( value , out VariantsBlockEditorValue ? result ) )
51
46
{
52
47
return null ;
53
48
}
54
49
55
50
await ToArtifactAsync ( result , dependencies , contextCache , cancellationToken ) . ConfigureAwait ( false ) ;
56
51
52
+ // If we don't have a store id then we can't extract the product attribute dependencies
53
+ // so we can just return the serialized value and hope the product attributes are there
54
+ if ( ! jsonSerializer . TryDeserialize ( value , out VariantsBlockEditorValueBase ? storeValue ) || ! storeValue . StoreId . HasValue )
55
+ {
56
+ return jsonSerializer . Serialize ( result ) ; ;
57
+ }
58
+
57
59
IEnumerable < string > ? productAttributeAliases = result . GetLayouts ( ) ? . SelectMany ( x => x . Config . Attributes . Keys )
58
60
. Distinct ( ) ;
59
61
@@ -73,6 +75,8 @@ public class UmbracoCommerceVariantsEditorValueConnector(
73
75
74
76
var artifact = jsonSerializer . Serialize ( result ) ;
75
77
78
+ // The block grid json converter will strip any none expected properties so we need to
79
+ // temporarily deserialize the artifact as a generic JsonObject and add the store id back in
76
80
JsonObject ? artifactJson = jsonSerializer . Deserialize < JsonObject > ( artifact . ToString ( ) ! ) ;
77
81
78
82
artifactJson ! . Remove ( "storeId" ) ;
@@ -98,7 +102,9 @@ public class UmbracoCommerceVariantsEditorValueConnector(
98
102
{
99
103
return artifact ;
100
104
}
101
-
105
+
106
+ // The block grid json converter will strip any none expected properties so we need to
107
+ // temporarily deserialize the artifact as a generic JsonObject and add the store id back in
102
108
JsonObject ? artifactJson = jsonSerializer . Deserialize < JsonObject > ( artifact . ToString ( ) ! ) ;
103
109
104
110
artifactJson ! . Remove ( "storeId" ) ;
0 commit comments