-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.py
More file actions
43 lines (34 loc) · 1.16 KB
/
lib.py
File metadata and controls
43 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import datetime
import time
from shpy import ProductsPy,CollectionPy
def get_month_ago():
time = (datetime.date.today().replace(day=1) - datetime.timedelta(days=1)).replace(day=1)
return str(time)
def products_from_month_ago(month_ago):
p = ProductsPy()
p.PRODUCT_LIST = []
ids = []
p.getAllProductsByStatus(status="active&limit=250&published_at_min="+month_ago)
for item in p.PRODUCT_LIST:
print(item["title"])
ids.append(item["id"])
return ids
def older_products(month_ago):
p = ProductsPy()
p.PRODUCT_LIST = []
ids = []
p.getAllProductsByStatus(status="active&limit=250&collection_id=404829798645&published_at_max="+month_ago)
for item in p.PRODUCT_LIST:
print(item["title"])
ids.append(item["id"])
return ids
def remove_old_products(oldproducts):
collection = CollectionPy()
for product in oldproducts:
time.sleep(1)
r = collection.removeFromCollection(product,404829798645)
def add_new_products(newproducts):
collection = CollectionPy()
time.sleep(.5)
for product in newproducts:
collection.addItemToExistingCollection(product,404829798645)