Skip to content

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

Remove filter on queryset in prepare_attribute_products_data

IKarbowiak15cbd5888c81
diff --git a/saleor/csv/utils/export.py b/saleor/csv/utils/export.py
index df450ca0ad..71aac49121 100644
--- a/saleor/csv/utils/export.py
+++ b/saleor/csv/utils/export.py
@@ -74,7 +74,6 @@ def export_products(
file_name,
file_type,
)
- send_email_with_link_to_download_csv(export_file, "export_products_success")
def get_filename(model_name: str, file_type: str) -> str:
@@ -167,7 +166,7 @@ def export_products_in_batches(
else:
append_to_file(export_data, headers, export_file, file_type, delimiter)
- send_email_with_link_to_download_csv(export_file, "export_products")
+ send_email_with_link_to_download_csv(export_file, "export_products_success")
def create_csv_file_and_save_in_export_file(
diff --git a/saleor/csv/utils/products_data.py b/saleor/csv/utils/products_data.py
index dbd2da98e8..3ef1ecb494 100644
--- a/saleor/csv/utils/products_data.py
+++ b/saleor/csv/utils/products_data.py
@@ -265,7 +265,7 @@ def prepare_products_relations_data(
def prepare_attribute_products_data(
- queryset: "QuerySet", attribute_ids: Optional[List[int]],
+ queryset: "QuerySet", attribute_ids: List[int],
):
result_data: Dict[int, dict] = defaultdict(dict)
@@ -273,19 +273,19 @@ def prepare_attribute_products_data(
fields = set(attribute_fields.values())
fields.add("pk")
- attribute_data = queryset.filter(
- attributes__assignment__attribute__pk__in=attribute_ids
- ).values(*fields)
+ attribute_data = queryset.values(*fields)
for data in attribute_data.iterator():
pk = data.get("pk")
- attribute = {
- "slug": data[attribute_fields["slug"]],
- "value": data[attribute_fields["value"]],
- }
- result_data = add_attribute_info_to_data(
- pk, attribute, "product attribute", result_data
- )
+ attribute_pk = data.pop(attribute_fields["attribute_pk"])
+ if str(attribute_pk) in attribute_ids:
+ attribute = {
+ "slug": data[attribute_fields["slug"]],
+ "value": data[attribute_fields["value"]],
+ }
+ result_data = add_attribute_info_to_data(
+ pk, attribute, "product attribute", result_data
+ )
return result_data