Products Sample - ProductDetailsView template error

Posted by Community Admin on 05-Aug-2018 10:39

Products Sample - ProductDetailsView template error

All Replies

Posted by Community Admin on 04-Mar-2011 00:00

I'm running the Products sample code from SP1 but it crashes with the following exception when using the ProductsView widget on a page.

The problem seems to be it can't find the embedded template ProductCatalogSample.Web.UI.Public.FrontendProductsDetailsView.ascx, because when you try and edit the detail template - Full Product it is blank.

I've looked at the sample code for ProductDetailsView but am struggling to find where the problem is, any ideas ?

Thanks
Euan

Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : More than one item in the sequence.
Source : Telerik.Sitefinity
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Object ExecuteKnownType[TResult](Telerik.OpenAccess.IObjectScope, System.String, Boolean, Int32, Int32, System.Collections.IList, Telerik.Sitefinity.Data.Linq.ElementOperator)
Stack Trace :    at Telerik.Sitefinity.Data.Linq.Oql.OqlQueryProvider`2.ExecuteKnownType[TResult](IObjectScope scope, String queryText, Boolean isEnumerable, Int32 skip, Int32 take, IList parameters, ElementOperator op)
   at Telerik.Sitefinity.Data.Linq.Oql.OqlQueryProvider`2.Execute[TResult](Expression expression)
   at Telerik.Sitefinity.Data.Linq.QueryProvider`2.System.Linq.IQueryProvider.Execute[T](Expression expression)
   at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
   at Telerik.Sitefinity.Web.UI.ControlUtilities.GetControlTemplate(String key, Expression`1 predicate)
   at Telerik.Sitefinity.Web.UI.ControlUtilities.GetTemplate(TemplateInfo info)
   at Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.ViewBase.get_LayoutTemplate()
   at Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.ViewBase.get_Container()
   at Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.ViewBase.CreateChildControls()
   at System.Web.UI.Control.EnsureChildControls()
   at System.Web.UI.WebControls.CompositeControl.get_Controls()
   at Telerik.Sitefinity.Web.UI.ContentUI.ContentView.LoadView(String viewName)
   at Telerik.Sitefinity.Web.UI.ContentUI.ContentView.CreateChildControls()
   at System.Web.UI.Control.EnsureChildControls()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
Additional Info:
 
MachineName : WG-CW-SDEV2A
TimeStamp : 04/03/2011 09:18:50
FullName : Telerik.Sitefinity.Utilities, Version=4.0.1210.0, Culture=neutral, PublicKeyToken=b28c218413bdf563


Posted by Community Admin on 10-Mar-2011 00:00

Hi Euan,

I tried to reproduce your issue but to could not get to success. Is this a brand new installation or upgrade?

Can you send us this scenario into an isolated sample project so we can try it there?


All the best,
George
the Telerik team

Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

Posted by Community Admin on 11-Mar-2011 00:00

Hi George,

It is a brand new installation. I just registered the product sample module, then created a new page dropped the product widget onto it. Then if you close the page and reopen it or view the published page it errors.

I've submitted my sample project as ticket 402440

Thanks
Euan

Posted by Community Admin on 11-Mar-2011 00:00

Hi George/Euan,

Has there been a resolution for this issue with "More than one item in the sequence"? I am receiving exactly the same error.

Thanks
Al

Posted by Community Admin on 11-Mar-2011 00:00

One quick note on this issue - I have noticed that there are duplicate widget templates for the products module i.e. each template exists twice.

One other thing, on the widget templates page, the module name shows as "null" unlike News/Blogs etc.

Al

Posted by Community Admin on 11-Mar-2011 00:00

Hi Higgsy,

As mentioned in my other post, I see the duplicates happening every time I build my Module then Site, the templates get reinstalled and are duplicated. If you build again there will be 3x, 4x etc. Only way around it is to restore clean database and restore site before every build.

Also for the template error I'm having this one too. I only have it when in the MasterListView.cs I try to get the module to use my own FrontEndTemplates as follows:

// This works, gets added with template code available for editing
  internal const string titlesOnlyLayoutTemplateName = "Telerik.Sitefinity.Resources.Templates.Frontend.News.TitlesOnlyListView.ascx";
 // This template is added but when you edit there is nothing there  yes, the ascx file is set as embedded resource.
 internal const string titlesThumbnailSummaryTemplateName = "ProductCatalog.Resources.Templates.Frontend.Products.TitlesThumbnailsListView.ascx";


The template is added but if you edit it there is actually no content. If I manually paste in the code from the .ascx file then the "More than one item in the sequence" error goes away. Not sure if this is same issue but very well could be.

Again, I really wonder if anyone at Telerik has actually tried to use the sample Products module as all these issues are so easy to reproduce.

Hope that helps.
Phill

Posted by Community Admin on 11-Mar-2011 00:00

Phil,

I hadn't looked at the widget templates section for a while, I've just looked and there are 3 pages of the damn things!

Telerik - can you please provide a solution.

Thanks
higgsy

Posted by Community Admin on 11-Mar-2011 00:00

@higgsy, I could be mistaken but I'm pretty sure this is a new bug introduced with SP1, I don't remember getting multiple templates added before SP1. Also, if you have the lated SDK code you'll noticed the Taxonomies sample they added (the Blue/Red drop down) also gets installed with every build and eventually you'll have multiple duplicate values in that drop down as well...

I'm really starting to kick myself for betting on Sitefinity/Telerik, it's costing me daily as well as lost potential business because my clients are losing faith in me as well.

p.

Posted by Community Admin on 16-Mar-2011 00:00

Hi George,

Were you able to reproduce this problem, with the project I supplied ?


Euan

Posted by Community Admin on 17-Mar-2011 00:00

Hi guys,

Right, we have fixed this bug and I've attached the latest version of the ProductsModule sample which include the fix. This will go public with the next release.

All the best,
George
the Telerik team

Posted by Community Admin on 17-Mar-2011 00:00

Hi George,

To simplify the merge process can you let us know which files changed? Is is just the ProductsModule.cs file or do we need to do a merge/compare on all files? I'm looking to merge this fix into a module that is being customized and in progress. I know I can do this on my own but figured I'd ask just in case you might know which file changed.

Thanks for the fix!! Now if we could just get a sample with Image and Page selectors integrated I think we'd have a lot of happy devs!

Cheers,
Phill

Posted by Community Admin on 18-Mar-2011 00:00

George,

"Now if we could just get a sample with Image and Page selectors integrated I think we'd have a lot of happy devs"

I'll second that.  A bunch of us, I'm sure, are chomping at the bit for this one.

Happy to see a fixed Products Module for the dropdown/taxonomy case though.

- William

Posted by Community Admin on 18-Mar-2011 00:00

Hi George, Can we clarify which bug(s) have been fixed? What about the issue with the templates appearing multiple times? I'd also third the comment regarding page and image selectors. It's pretty hard to find a use for a module that wouldn't need this functionality, and I suspect I'm not alone in saying that the hardest thing about V4 is trying to select content - we desperately need some examples, please please please! Regards, Higgsy

Posted by Community Admin on 18-Mar-2011 00:00

Hi,

Here is the list of fixes that George sent me.

A few things were modified,

a) a new method for template registration called RegisterTemplateEmbeddedInProductsModule has been added to the ProductsModule.cs . It adds duplicate templates verification logic.

b) three new templates are introduced: TitlesOnlyListView.ascx, TitlesDatesListView.ascx, TitlesDatesSummariesListView.ascx and TitlesDatesContentsListView.ascx

c) the templates in MasterListView.cs were incorrect and were changed to the correct ones.

Euan

Posted by Community Admin on 18-Mar-2011 00:00

Hi All,

I notice the Duplicate Taxon bug hasn't been fixed, but here is my fix.

I've created a new function that only adds the Taxon if it doesn't already exist. You then call this from InstallCustomTaxonomies, see below.

Euan

private void CreateTaxon<TTaxon>(SiteInitializer initializer, Taxonomy taxonomy, string taxonName, string taxonTitle)
            where TTaxon : Taxon
        
 
            var taxon = taxonomy.Taxa.FirstOrDefault(t => t.Name == taxonName);
            if (taxon == null)
            
                taxon = initializer.TaxonomyManager.CreateTaxon<TTaxon>();
                taxon.Title = taxonTitle;
                taxon.Name = taxonName;
                taxonomy.Taxa.Add(taxon);
            
 
        

/// <summary>
       /// Installs the taxonomies.
       /// </summary>
       /// <param name="initializer">The initializer.</param>
       protected void InstallCustomTaxonomies(SiteInitializer initializer)
       
           //installs the default Tags and Category taxonomies
           this.InstallTaxonomy(initializer, typeof(ProductItem));
 
 
           var metaMan = initializer.Context.MetadataManager;
           var taxMan = initializer.TaxonomyManager;
 
           var flatTaxonomy = this.CreateTaxonomy<FlatTaxonomy>(initializer, "Colors", ColorsTaxonomyId, "Color");
 
           this.CreateTaxon<FlatTaxon>(initializer, flatTaxonomy, "Red", "Red");
           this.CreateTaxon<FlatTaxon>(initializer, flatTaxonomy, "Blue", "Blue");
 
           initializer.Context.SaveMetaData(true);
 
           var type = metaMan.GetMetaType(typeof(ProductItem));
           if (type == null)
           
               type = metaMan.CreateMetaType(typeof(ProductItem));
           
 
           if (type.Fields.ToList().Any(fld => fld.FieldName == "Colors"))
           
               var field = metaMan.CreateMetafield("Colors");
               field.TaxonomyProvider = taxMan.Provider.Name;
               field.TaxonomyId = ColorsTaxonomyId;
               field.IsSingleTaxon = false;
               type.Fields.Add(field);
           
 
           //initializer.Context.MetadataManager.SaveChanges(false);
 
           initializer.Context.SaveChanges();
 
       

Posted by Community Admin on 21-Mar-2011 00:00

does anyone else get a 404 when trying to view the "Comments for products" section of the products module?

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.
 
Requested URL: /sitefinity/Content/Products/Comments



Posted by Community Admin on 23-Mar-2011 00:00

Hello Euan,

Thanks for the fix! We have added some points to your account. We have reworked the module quite a lot, but still, we appreciate the efforts you have put in.

Drew, 
Can you put a break point somewhere, and check if it will be hit? Is the request processed by Asp.Net, or it's thrown by IIS?

Best wishes,
Georgi
the Telerik team

Posted by Community Admin on 23-Mar-2011 00:00

Hey Georgi,
Thanks for the response. The 404 error is thrown by asp.net not IIS. Where would a break point be valuable, I'm not seeing where any back end code is being hit for the comment section.

Posted by Community Admin on 23-Mar-2011 00:00

Hi all,

Has anyone had problems with the products module when you go to Administration > Permissions. I tried the module that was released with SP1, and the one that was attached to this thread, and both produce the error 

Could not find the key "Products" or class "ProductsResources".

If I add an entry to the resources file, i.e.

[ResourceEntry("Products",
Value="Products")]
public string Products
get
return this["Products"];



Then it works. It seems like an odd one, because when the permission set is installed, it should be using the constant PermissionSetName.

Has anyone else experienced this?

Thanks
higgsy

Posted by Community Admin on 06-Apr-2011 00:00

higgsy,

Thanks so much for posting your problem and solution.  I just ran into the same thing and fixed it in the same manner.

- William

This thread is closed