Skip to content

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

Deprecate invalid sorters

Krzysztof Świątekcbc3de3de615
diff --git a/saleor/graphql/product/sorters.py b/saleor/graphql/product/sorters.py
index 0dd9de7bab..b511366e5d 100644
--- a/saleor/graphql/product/sorters.py
+++ b/saleor/graphql/product/sorters.py
@@ -15,10 +15,12 @@ class AttributeSortField(graphene.Enum):
FILTERABLE_IN_STOREFRONT = ["filterable_in_storefront", "name", "slug"]
FILTERABLE_IN_DASHBOARD = ["filterable_in_dashboard", "name", "slug"]
+ # Deprecated: doesn't work
DASHBOARD_VARIANT_POSITION = [
"attributevariant__sort_order",
"attributevariant__id",
]
+ # Deprecated: doesn't work
DASHBOARD_PRODUCT_POSITION = [
"attributeproduct__sort_order",
"attributevariant__id",
@@ -51,10 +53,10 @@ class AttributeSortField(graphene.Enum):
"Sort attributes by their position in storefront"
),
AttributeSortField.DASHBOARD_VARIANT_POSITION.name: (
- "Sort variant attributes by their position in dashboard."
+ "Deprecated: Sort variant attributes by their position in dashboard."
),
AttributeSortField.DASHBOARD_PRODUCT_POSITION.name: (
- "Sort product attributes by their position in dashboard."
+ "Deprecated: Sort product attributes by their position in dashboard."
),
AttributeSortField.AVAILABLE_IN_GRID.name: (
"Sort attributes based on whether they can be displayed "
diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.py
index 71cb6c083f..d48e55557f 100644
--- a/tests/api/test_attributes.py
+++ b/tests/api/test_attributes.py
@@ -1936,41 +1936,6 @@ def test_sort_attributes_by_slug(api_client):
assert attributes[1]["node"]["slug"] == "b"
- "sort_field, m2m_model",
- (
- ("DASHBOARD_VARIANT_POSITION", AttributeVariant),
- ("DASHBOARD_PRODUCT_POSITION", AttributeProduct),
- ),
-)
-def test_sort_attributes_by_position_in_product_type(
- api_client,
- color_attribute,
- size_attribute,
- sort_field: str,
- m2m_model: Union[AttributeVariant, AttributeProduct],
-):
- """Sorts attributes for dashboard custom ordering inside a given product type."""
-
- product_type = ProductType.objects.create(name="My Product Type")
- m2m_model.objects.create(
- product_type=product_type, attribute=color_attribute, sort_order=0
- )
- m2m_model.objects.create(
- product_type=product_type, attribute=size_attribute, sort_order=1
- )
-
- variables = {"sortBy": {"field": sort_field, "direction": "DESC"}}
-
- attributes = get_graphql_content(
- api_client.post_graphql(ATTRIBUTES_SORT_QUERY, variables)
- )["data"]["attributes"]["edges"]
-
- assert len(attributes) == 2
- assert attributes[0]["node"]["slug"] == "size"
- assert attributes[1]["node"]["slug"] == "color"
-
-
def test_sort_attributes_by_default_sorting(api_client):
"""Don't provide any sorting, this should sort by slug by default."""
Attribute.objects.bulk_create(