8 Phases refactor
This commit is contained in:
@@ -475,72 +475,10 @@ class ContentSyncService:
|
||||
client: WordPressClient
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Ensure taxonomies exist in WordPress before publishing content.
|
||||
|
||||
Args:
|
||||
integration: SiteIntegration instance
|
||||
client: WordPressClient instance
|
||||
|
||||
Returns:
|
||||
dict: Sync result with synced_count
|
||||
DEPRECATED: Legacy SiteBlueprint taxonomy sync removed.
|
||||
Taxonomy management now uses ContentTaxonomy model.
|
||||
"""
|
||||
try:
|
||||
from igny8_core.business.site_building.models import SiteBlueprint, SiteBlueprintTaxonomy
|
||||
|
||||
# Get site blueprint
|
||||
blueprint = SiteBlueprint.objects.filter(
|
||||
account=integration.account,
|
||||
site=integration.site
|
||||
).first()
|
||||
|
||||
if not blueprint:
|
||||
return {'success': True, 'synced_count': 0}
|
||||
|
||||
synced_count = 0
|
||||
|
||||
# Get taxonomies that don't have external_reference (not yet synced)
|
||||
taxonomies = SiteBlueprintTaxonomy.objects.filter(
|
||||
site_blueprint=blueprint,
|
||||
external_reference__isnull=True
|
||||
)
|
||||
|
||||
for taxonomy in taxonomies:
|
||||
try:
|
||||
if taxonomy.taxonomy_type in ['blog_category', 'product_category']:
|
||||
result = client.create_category(
|
||||
name=taxonomy.name,
|
||||
slug=taxonomy.slug,
|
||||
description=taxonomy.description
|
||||
)
|
||||
if result.get('success'):
|
||||
taxonomy.external_reference = str(result.get('category_id'))
|
||||
taxonomy.save(update_fields=['external_reference'])
|
||||
synced_count += 1
|
||||
elif taxonomy.taxonomy_type in ['blog_tag', 'product_tag']:
|
||||
result = client.create_tag(
|
||||
name=taxonomy.name,
|
||||
slug=taxonomy.slug,
|
||||
description=taxonomy.description
|
||||
)
|
||||
if result.get('success'):
|
||||
taxonomy.external_reference = str(result.get('tag_id'))
|
||||
taxonomy.save(update_fields=['external_reference'])
|
||||
synced_count += 1
|
||||
except Exception as e:
|
||||
logger.warning(f"Error syncing taxonomy {taxonomy.id} to WordPress: {e}")
|
||||
continue
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
'synced_count': synced_count
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"Error syncing taxonomies to WordPress: {e}", exc_info=True)
|
||||
return {
|
||||
'success': False,
|
||||
'error': str(e),
|
||||
'synced_count': 0
|
||||
}
|
||||
return {'success': True, 'synced_count': 0}
|
||||
|
||||
def _sync_products_from_wordpress(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user