Geta / geta-optimizely-categories

An alternative to Optimizely's default category functionality, where categories are instead stored as localizable IContent.
5 stars 10 forks source link

Categories not synchronizing to Optimizely Graph #39

Closed dluk closed 3 months ago

dluk commented 5 months ago

When synchronizing content to Optimizely Graph categories itself are not synchronized and content links expanded from Graph query are also empty for categories. Query to graph: query test { DetailPage { items { Categories { Id Expanded { Name ParentLink { Id } } } } }

response from graph:

"data": {
    "DetailPage": {
        "items": [
            {
                "Categories": [
                    {
                        "Id": 29274,
                        "Expanded": {
                            "Name": null,
                            "ParentLink": {
                                "Id": null
                            }
                        }
                    }
                ]
            }
        ]
    }
}

After some debugging it appears that Graph content serializer Optimizely.ContentGraph.Cms.Core.Internal.ContentSerializer only supports these Base content types:

public string[] SupportedContentBaseTypes
{
  get
  {
    return new string[11]
    {
      "Page",
      "Media",
      "Image",
      "Video",
      "Block",
      "Catalog",
      "Node",
      "Product",
      "Variation",
      "Bundle",
      "Package"
    };
  }
}

And category types are stored in database table [dbo].[tblContentType] with Base column as NULL. SQL query:

SELECT [ModelType]
      ,[Name]
      ,[MetaDataInherit]
      ,[MetaDataDefault]
      ,[ContentType]
      ,[Base]
      ,[Version]
      ,[SupportedMediaExtensions]
      ,[GroupName]
FROM .[dbo].[tblContentType]
WHERE ModelType like 'Geta%'
OR Name = 'SiteCategory'

Query result: image

Our SiteCategory class:

[ContentType]
public class SiteCategory : CategoryData
{
    [Display(Name = "Display Text")]
    [CultureSpecific]
    public virtual string DisplayText { get; set; }
}

And Categories property on DetailPage content type:

[Display(Name = "Categories")]
[Categories]
public virtual IList<ContentReference> Categories { get; set; }

Will this be fixed and is there a workaround to make it synchronize categories to Optimizely Graph?

frederikvig commented 3 months ago

Optimizely would need to add support for the ContentBase content type in Optimizely.ContentGraph.Cms.Core.Internal.ContentSerializer

public string[] SupportedContentBaseTypes
{
  get
  {
    return new string[11]
    {
      "Page",
      "Media",
      "Image",
      "Video",
      "Block",
      "Catalog",
      "Node",
      "Product",
      "Variation",
      "Bundle",
      "Package"
    };
  }
}
frederikvig commented 3 months ago

This has been flagged with the Optimizely Product / Engineering teams.