-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A/B testing of components return "Data source invalid." #442
Comments
This is odd because the revision field is a standard field in Sitecore and should get populated when the item is saved. What do you see in the raw values for the item? |
Yes, I agree that the issue is odd especially since I tested multiple components and all of them inherit from the standard template and all the standard template fields are populated as expected but not in Glass. In the raw values for the revision field I see "e07f9b7e-7b11-419d-8ae0-9fd28ee338f5". Looks like it is not only our issue - https://sitecore.stackexchange.com/questions/30224/a-b-testing-of-components-using-glass-mapper-return-data-source-invalid but the fix does not fully work for me. Below is the GlassBaseController code we are using with a partial fix for the issue form Stack Exchange, but this is only showing one of the component variants correctly. When I assign two variants to different datasources then only one datasource (always the same) is visible for both variants in Experience Editor. But it is possible to edit at least preview/edit one of them instead of none of them.
this.MvcContext.GetDataSourceItem(); returns null, however this.MvcContext.DataSourceItem is populated correctly. I also noticed that when trying to CreateItemByIdOptions this.MvcContext.DataSourceItem.Language is incorrect (en) but the Sitecore.Context.Language is correct (nl-NL). So when I change the language like in the code sample above it is coming through. There is no item version in English but there is in Dutch. |
I am assuming the model isn't cached |
@izabelawlodarska could we setup a screensharing session? |
I am using Sitecore 9.3 with Glass Mapper 5.8.177 and component A/B testing does not work for me.
I set up a simple component that works perfectly fine until I create component A/B testing variants. After that, I am getting the "Data source is invalid." error for both variants. I saw this was an issue previously and there were some PR that was merged saying that this was fixed in the version I am using but it still does not seem to be working for me.
The problematic method is:
var datasource = MvcContext.GetDataSourceItem<T>();
which returns null.
After debugging it seems that the item is resolved correctly until the Glass.Mapper.Sc.Pipelines.ObjectConstruction.ItemVersionCountByRevisionTask, void Execute(ObjectConstructionArgs args) method is reached.
The condition below fails because the Revision field does not exist in the Item Fields
The debugger shows that the scContext.Item.Fields do not contain the Revision field so it returns null. The only field which is visible in my item while debugging is "__Originator"-{F6D8A61C-2F84-4401-BD24-52D2068172BC}. There are also no custom fields mapped as well.
I tried setting A/B testing also for different components - the same issue for all of them. All of the components inherit from StandardTemplate and Revision field is present on the items when I check that from Sitecore. Also, all of the components are being displayed and are working fine as long as no A/B testing is used.
When I check MvcContext.DataSourceItem value after MvcContext.GetDataSourceItem(); it seems that the items were set correctly in the DataSourceItem, they are just unable to be mapped to a model.
Any ideas on what is happening here and how to resolve these issues would be more than welcome.
The text was updated successfully, but these errors were encountered: