Last active
June 10, 2025 10:36
-
-
Save ketul-andev/d8b9d0afba9ec1ffddc82bb61fea2c90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shopify_core.models import Plan, Subscription, ShopifyConfiguration, Shop | |
from datetime import datetime | |
shop_ids = ShopifyConfiguration.objects.filter(app_id='FACEBOOK_PIXEL', active=True).values_list('shop', flat=True) | |
shops = Shop.objects.filter(id__in=shop_ids) | |
#inactive plan with same features as advanced plan | |
plan = Plan.objects.get(id=37) | |
subscriptions = [] | |
for shop in shops: | |
subscription = Subscription( | |
shop=shop, plan=plan, merchant_center_account=None, created_on=datetime.now(), | |
adwords_account=None, active=True, test=False, | |
recurring_charge_id=None, cancelled_on=None) | |
subscriptions.append(subscription) | |
Subscription.objects.bulk_create(subscriptions) | |
print(f"Created {len(subscriptions)} subscriptions") |
Add logs as well if needed.
@Yash-Adnabu Done
Approved.
Approved
Approved
Approved.
Why are we basing this on shop configurations? Are all stores going to have a configuration? Even historically?
There was a time when the facebook pixel app did not require any configuration to function (I could be wrong). Should the app be restricted for those older customers?
If not, consider using credentials instead.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're doing this for a large number of shops, use bulk_create.