2

Is there a way to make Glass mapper work with non-shared fields when mapping items from Sitecore in a fallbacked langauge version of the item.

Glass is able to map only shared fields to my model. My Sitecore item has values in English and the German language falls back to English. When i ask for the German version of the item, I get back an item which has values only for the shared fields.

I am using glass mapper v4 and Sitecore 8.1.

My Application_BeginRequest method looks like this:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    Sitecore.Context.Items["Disable"] = new VersionCountDisabler();
}

and my class looks like this:

[SitecoreType(AutoMap = true)]
public class CustomModel
{
    [SitecoreField]
    public virtual string Title { get; set; }

    [SitecoreField]
    public virtual string Description { get; set; }

    [SitecoreField("Another field")]
    public virtual string AnotherField{ get; set; }
 }

Thanks!

1 Answer 1

2

Can you try to use VersionCountDisabler when you return your model?

var sitecoreContext = new SitecoreContext();
using (new VersionCountDisabler())
{
   Model1 = sitecoreContext.GetCurrentItem<Model>();
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.