Sitecore / Habitat

Sitecore Modular Architecture Example
Other
413 stars 397 forks source link

Experience Editor: Changing associated content resolves datasources from wrong database. #282

Open rolek opened 7 years ago

rolek commented 7 years ago

Consider the following scenario.

I am a developer on the project. I have just created a new view rendering, defined new datasource location under my site/Settings/Datasource. I am adding a newly defined view rendering to the current page in Experience Editor. The datasource location dialog does not show my defined datasource.

The cause: I have tracked the issue to the following class: SIteDefinitionsProvider

private SiteDefinition GetSiteByHierarchy(Item item) { var siteItem = this.GetSiteItemByHierarchy(item); return siteItem == null ? null : this.SiteDefinitions.FirstOrDefault(s => s.Item.ID == siteItem.ID); }

siteItem is from master database, s.item.id is from web database, resulting return statement returns the item from web database, when I am working in Experience Editor and adding / changing components.

This causes incorrect datasource locations for the component I am working on.

Eldblom-zz commented 7 years ago

Very interesting. Could you possibly describe how to recreate this bug?

rolek commented 7 years ago

To reproduce: DO not publish anything yet. 1) Create View Rendering, Set datasource to: site: 2) Create DataSource under the Datasources folder, choose your newly created view rendering when asked. 3) Configure the new datasource with template and location. 4) Create or edit the page in Experience Editor. Add view from point 1. 5) Set associated content. The Set Associated Content dialog will not show your location from point 3.

Now Publish the site. Try setting associated content for the view rendering that you just created. Everything works fine and datasource location shows up correctly.