Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. def export_csv_products():
  2.     from pandas import DataFrame
  3.     from django.db.models import Q
  4.  
  5.     list_product_path = os.path.join(
  6.         PROJECT_ROOT, "saleor", "static", "list_product.csv"
  7.     )
  8.  
  9.     products = Product.objects.\
  10.         filter(Q(is_published_north=True) | Q(is_published_south=True))
  11.     list_product = []
  12.  
  13.     for product in products:
  14.         list_product.append({
  15.             'Barcode': product.adr_barcode,
  16.             'SAP': product.sap_mapping,
  17.             'Unit Code': product.unit_code,
  18.             'url': product.get_absolute_url()
  19.         })
  20.  
  21.     df = DataFrame(list_product)
  22.     df.to_csv(list_product_path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement