Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix productVariantBulkUpdate not saved fields to DB (#17342)

Krzysztof Żurawaea05da547c8
diff --git a/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py b/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
index a6e90f5f8c..111dbcbd6c 100644
--- a/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
+++ b/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
@@ -700,8 +700,12 @@ class ProductVariantBulkUpdate(BaseMutation):
"metadata",
"private_metadata",
"external_reference",
+ "preorder_end_date",
+ "preorder_global_threshold",
+ "is_preorder",
],
)
+
if error_policy == ErrorPolicyEnum.REJECT_EVERYTHING.value:
warehouse_models.Stock.objects.bulk_create(stocks_to_create)
else:
diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
index 0c73bfe6ff..c5f177200e 100644
--- a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
+++ b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
@@ -119,6 +119,10 @@ def test_product_variant_bulk_update(
{
"id": variant_id,
"name": new_name,
+ "preorder": {
+ "endDate": "2022-12-12T12:12:12Z",
+ "globalThreshold": 10,
+ },
"metadata": [{"key": metadata_key, "value": metadata_value}],
}
]
@@ -148,6 +152,12 @@ def test_product_variant_bulk_update(
for rule in get_active_catalogue_promotion_rules():
assert rule.variants_dirty
+ variant.refresh_from_db()
+
+ assert variant.preorder_end_date
+ assert variant.preorder_global_threshold
+ assert variant.is_preorder
+
@pytest.mark.parametrize(
"error_policy",