fix product tags
This commit is contained in:
parent
2dc7f1e89d
commit
74c1b7069a
|
|
@ -40,7 +40,6 @@ class Command(BaseCommand):
|
|||
TagCategory.objects.bulk_create(objects)
|
||||
self.stdout.write(self.style.WARNING(f'Add or get tag category objects.'))
|
||||
|
||||
|
||||
def product_type_category_sql(self):
|
||||
with connections['legacy'].cursor() as cursor:
|
||||
cursor.execute('''
|
||||
|
|
@ -56,9 +55,9 @@ class Command(BaseCommand):
|
|||
|
||||
def add_type_product_category(self):
|
||||
for c in tqdm(self.product_type_category_sql(), desc='Add type product category'):
|
||||
type = ProductType.objects.get(index_name='wine')
|
||||
type = ProductType.objects.get(index_name=ProductType.WINE)
|
||||
category = TagCategory.objects.get(index_name=c.tag_category)
|
||||
if type and category not in type.tag_categories.all():
|
||||
if category not in type.tag_categories.all():
|
||||
type.tag_categories.add(category)
|
||||
|
||||
self.stdout.write(self.style.WARNING(f'Add type product category objects.'))
|
||||
|
|
@ -116,7 +115,7 @@ class Command(BaseCommand):
|
|||
select
|
||||
DISTINCT
|
||||
m.product_id,
|
||||
lower(trim(CONVERT(m.value USING utf8))) as tag_value,
|
||||
trim(CONVERT(m.value USING utf8)) as tag_value,
|
||||
trim(CONVERT(v.key_name USING utf8)) as tag_category
|
||||
FROM product_metadata m
|
||||
JOIN product_key_value_metadata v on v.id = m.product_key_value_metadatum_id
|
||||
|
|
@ -133,7 +132,7 @@ class Command(BaseCommand):
|
|||
)
|
||||
product = Product.objects.get(old_id=t.product_id)
|
||||
for tag in tags:
|
||||
if product not in tag.products.all():
|
||||
if tag not in product.tags.all():
|
||||
product.tags.add(tag)
|
||||
|
||||
self.stdout.write(self.style.WARNING(f'Add or get tag objects.'))
|
||||
|
|
|
|||
|
|
@ -503,4 +503,4 @@ ESTABLISHMENT_CHOSEN_TAGS = ['gastronomic', 'en_vogue', 'terrace', 'streetfood',
|
|||
NEWS_CHOSEN_TAGS = ['eat', 'drink', 'cook', 'style', 'international', 'event', 'partnership']
|
||||
INTERNATIONAL_COUNTRY_CODES = ['www', 'main', 'next']
|
||||
|
||||
#ELASTICSEARCH_DSL_AUTOSYNC = False
|
||||
ELASTICSEARCH_DSL_AUTOSYNC = False
|
||||
|
|
|
|||
|
|
@ -80,11 +80,11 @@ LOGGING = {
|
|||
'py.warnings': {
|
||||
'handlers': ['console'],
|
||||
},
|
||||
'django.db.backends': {
|
||||
'handlers': ['console', ],
|
||||
'level': 'DEBUG',
|
||||
'propagate': False,
|
||||
},
|
||||
# 'django.db.backends': {
|
||||
# 'handlers': ['console', ],
|
||||
# 'level': 'DEBUG',
|
||||
# 'propagate': False,
|
||||
# },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user