Sitefinity 6.1 upgrade - Ecommerce/Products gives error

Posted by Community Admin on 04-Aug-2018 15:37

Sitefinity 6.1 upgrade - Ecommerce/Products gives error

All Replies

Posted by Community Admin on 02-Aug-2013 00:00

Hi.
After upgrading to 6.1, when I click on eCommerce / Products, I get an error : Sequence contains no elements
Anybody had the same issue?  Anybody knows a fix for this?
Thanks!
Olivier

Posted by Community Admin on 05-Aug-2013 00:00

Hi Olivier,

 We will continue troubleshooting this with you in your tickets. For anyone else having this problem the following script seems to resolve it for most projects. 

using System;
 
using System.Collections.Generic;
 
using System.Globalization;
 
using System.Linq;
 
using Telerik.OpenAccess;
 
using Telerik.Sitefinity.Ecommerce.Catalog.Model;
 
using Telerik.Sitefinity.Modules.Ecommerce.Catalog;
 
using Telerik.Sitefinity.Services;
 
   
 
namespace SitefinityWebApp
 
 
                public partial class WebForm1 : System.Web.UI.Page
 
                
 
                                protected void Page_Load(object sender, EventArgs e)
 
                                
 
                                                UpdateExistingProductsWithoutLifecycleSupport();
 
                                                Response.Write("All done!");
 
   
 
                                                 
 
                                
 
                                private void UpdateExistingProductsWithoutLifecycleSupport()
 
                                
 
                                                   
 
                                                   
 
                                                                List<Guid> inactiveProducts = CreateMasterProductsFromLiveOnes();
 
   
 
                                                                PublishAllMasterProducts();
 
   
 
                                                                UnpublishTheNotActiveProducts(inactiveProducts);
 
                                                   
 
                                
 
                                private void UnpublishTheNotActiveProducts(List<Guid> inactiveProducts)
 
                                
 
                                                using (var catalogManager = CatalogManager.GetManager())
 
                                                
 
                                                                var products = catalogManager.GetProducts().Where(p => p.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);
 
   
 
                                                                int skip = 0;
 
                                                                int take = 100;
 
                                                                int currentCount = 0;
 
                                                                int totalCount = products.Count();
 
   
 
                                                                while (currentCount < totalCount)
 
                                                                
 
                                                                                var chunkedProducts = products.Skip(skip).Take(take);
 
                                                                                skip = skip + take;
 
                                                                                currentCount = skip;
 
   
 
                                                                                foreach (var productLive in chunkedProducts)
 
                                                                                
 
                                                                                                try
 
                                                                                                
 
                                                                                                                //all inactive old versions should be made invisible.
 
                                                                                                                if (inactiveProducts.Contains(productLive.OriginalContentId))
 
                                                                                                                
 
                                                                                                                                var publishedTranslations = new List<string>(productLive.PublishedTranslations.ToList()); //copy since the collection will be modified by the unpublish durring the loop
 
                                                                                                                                if (publishedTranslations.Count() > 0) //unpublish for each translation
 
                                                                                                                                
 
                                                                                                                                                foreach (var publishedTranslation in publishedTranslations)
 
                                                                                                                                                
 
                                                                                                                                                                catalogManager.Lifecycle.Unpublish(productLive, new CultureInfo(publishedTranslation));
 
                                                                                                                                                                catalogManager.Provider.FlushTransaction();
 
                                                                                                                                                
 
                                                                                                                                
 
                                                                                                                                else //unpublish invariant only
 
                                                                                                                                
 
                                                                                                                                                catalogManager.Lifecycle.Unpublish(productLive, SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage);
 
                                                                                                                                                catalogManager.Provider.FlushTransaction();
 
                                                                                                                                
 
                                                                                                                                catalogManager.SaveChanges();
 
                                                                                                                
 
                                                                                                
 
                                                                                                catch (Exception innerEx)
 
                                                                                                
 
                                                                                                                 
 
                                                                                                
 
                                                                                
 
                                                                
 
                                                
 
                                
 
                                private void PublishAllMasterProducts()
 
                                
 
                                                using (var catalogManager = CatalogManager.GetManager())
 
                                                
 
                                                                var products = catalogManager.GetProducts().Where(p => p.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master);
 
   
 
                                                                int skip = 0;
 
                                                                int take = 100;
 
                                                                int currentCount = 0;
 
                                                                int totalCount = products.Count();
 
   
 
                                                                while (currentCount < totalCount)
 
                                                                
 
                                                                                var chunkedProducts = products.Skip(skip).Take(take);
 
                                                                                skip = skip + take;
 
                                                                                currentCount = skip;
 
   
 
                                                                                foreach (var productMaster in chunkedProducts)
 
                                                                                
 
                                                                                                try
 
                                                                                                
 
                                                                                                                var publishedTranslations = productMaster.PublishedTranslations;
 
                                                                                                                if (publishedTranslations.Count() > 0) //publish for each translation
 
                                                                                                                
 
                                                                                                                                foreach (var publishedTranslation in publishedTranslations)
 
                                                                                                                                
 
                                                                                                                                                catalogManager.Lifecycle.Publish(productMaster, new CultureInfo(publishedTranslation));
 
                                                                                                                                                catalogManager.Provider.FlushTransaction();
 
                                                                                                                   
 
                                                                                                                
 
                                                                                                                else //publish for default
 
                                                                                                                
 
                                                                                                                                catalogManager.Lifecycle.Publish(productMaster, SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage);
 
                                                                                                                                catalogManager.Provider.FlushTransaction();
 
                                                                                                                
 
                                                                                                                catalogManager.SaveChanges();
 
                                                                                                
 
                                                                                                catch (Exception innerEx)
 
                                                                                                
 
                                                                                                                   
 
                                                                                                
 
                                                                                
 
                                                                
 
                                                
 
                                
 
                                private List<Guid> CreateMasterProductsFromLiveOnes()
 
                                
 
                                                List<Guid> notActiveProducts = new List<Guid>();
 
   
 
                                                Guid currentUserId = Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId();
 
   
 
                                                using (var catalogManager = CatalogManager.GetManager())
 
                                                
 
                                                                var products = catalogManager.GetProducts().Where(p => p.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && p.OriginalContentId == null); // yes it should be null not Guild.Empty
 
   
 
                                                                foreach (Product productLive in products)
 
                                                                
 
                                                                                productLive.Status = Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master;
 
                                                                                var isActiveLegacy = productLive.FieldValue<bool>("isActive");
 
                                                                                //we cannot use reflection because open access has not populated the field yet so (bool)typeof(Product).GetField("isActive", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(productLive) will always return false
 
                                                                                if (!isActiveLegacy) //TODO use the internal method because the property IsActive now uses lifecycle
 
                                                                                
 
                                                                                                notActiveProducts.Add(productLive.Id);
 
                                                                                                productLive.ApprovalWorkflowState = "Unpublished";
 
                                                                                
 
                                                                   else
 
                                                                                
 
                                                                                                productLive.ApprovalWorkflowState = "Published";
 
                                                                                
 
                                                                                if (currentUserId != Guid.Empty)
 
                                                                                
 
                                                                                                productLive.Owner = currentUserId;
 
                                                                                                productLive.OriginalOwner = currentUserId;
 
                                                                                
 
                                                                
 
   
 
                                                                catalogManager.SaveChanges();
 
                                                
 
   
 
                                                return notActiveProducts;
 
                                
 
   
 
                     
 
                
 

Regards,
Patrick Dunn
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 05-Aug-2013 00:00

Thank you Patrick.
I was curious to see if others also had this issue.
I understand we will continue troubleshooting in my own ticket.
Thank you for taking the time to reply anyway!  Really appreciated.
Olivier

Posted by Community Admin on 25-Nov-2013 00:00

I have encountered this exact problem upgrading my site from 5.x to the latest 6.2.4910

I ran this script but, it did not fix the problem.

all of the products I had no longer appear on the website and when I click on ecommerce / products I receive the message "Sequence contains no elements."

Any suggestions?

Posted by Community Admin on 25-Nov-2013 00:00

Hi Gaston.
When I faced that problem, I turned out that I had skipped some of the upgrades.  You can't go directly from 5.x to 6.2.  There are important updates that need to take place in-between.
So, restore your 5.x you backed up before doing the upgrade - you did a backup right??? - and follow the upgrade path described on the following link : http://www.sitefinity.com/documentation/documentationarticles/installation-and-administration-guide/upgrade 
It is important you follow each upgrade by complete tests of all the functionality you have installed and use to ensure all is working as it should, or you will have more and more problems.

Good luck!

Posted by Community Admin on 08-Jan-2014 00:00

I know this thread is kind of old but i though i would post my findings.  So like every one here i upgrade from 5.4 to 6.1 and got the "Sequence contains no elements".  I tried running the script provided and now resolution.  

I investigated some more and realized that my product types were not showing either.  I looked into the database [sf_ec_product_type] and realized the that the 'title_plural' & 'title' where now  'title_plural_' & 'title_' i updated those columns and set the old ones to NULL.  Then i noticed that 'application_name' was looking for '/EcommerceCommon' i updated that column.

After all that i recycled the appPool & modified the web.config and to my surprise there where my Product Types.  

I ran that script again and VIOLA!!! My products!!!

Posted by Community Admin on 08-May-2014 00:00

I'd like to add one more solution, if anyone comes across this post and the script doesn't work for them. I updated from 5.4 to 7, and I got the popup sequence contains no elements on the Products screen as well.

 I changed the application_name field in the sf_ec_product_types table to be '/EcommerceCommon' instead of '/Catalog:'

update [sf_ec_product_type] set [application_name] = '/EcommerceCommon'

 That gave me both product types and products in the admin section. When I then went to create a new product I got an error saying something like ​Approval workflow could not be found for type Telerik.Sitefinity.DynamicTypes.Model.sf_ec_prdct_generalproduct. The fix for that was easy, I just pasted the following line into my WorkflowConfig.config file (in /App_Data/Sitefinity/Configuration/):

<add serviceUrl="~/DefaultWorkflows/ApprovalWorkflow.xamlx" title="General product &lt;i&gt;(Ecommerce)&lt;/i&gt;" moduleName="Ecommerce" contentType="Telerik.Sitefinity.DynamicTypes.Model.sf_ec_prdct_generalproduct" />

Posted by Community Admin on 30-Apr-2015 00:00

Josh,

I just upgraded from 5.0.2523 (Hotfix 1) to 8.0.5710 and I was getting the same error.  I tried Patrick Dunn's script and no luck.  I then ran your update script and added the additional entries into the workflowConfig.config file and and now I get a different error message when creating a new product or updating a product.  The message that pops up says...

There was an error deserializing the object of type System.String. End element 'root' from namespace '' expected. Found element 'Item' from namespace ''.

I compared the config files and assemblies to a clean installed of Sitefinity 8.0.5710 and I don't see anything that could be causing this issue.

Below is the full error message.  Any help would be greatly appreciated.

----------------------------------------
Timestamp: 4/30/2015 8:52:14 PM
 
Message: HandlingInstanceID: 2245f21b-d7ed-4bac-9ee6-1082dcd2edad
An exception of type 'System.Runtime.Serialization.SerializationException' occurred and was caught.
---------------------------------------------------------------------------------------------------
04/30/2015 16:52:14
Type : System.Runtime.Serialization.SerializationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : There was an error deserializing the object of type System.String. End element 'root' from namespace '' expected. Found element 'Item' from namespace ''.
Source : System.Runtime.Serialization
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Object ReadObjectHandleExceptions(System.Runtime.Serialization.XmlReaderDelegator, Boolean, System.Runtime.Serialization.DataContractResolver)
HResult : -2146233076
Stack Trace :    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
   at System.ServiceModel.Dispatcher.SingleBodyParameterDataContractMessageFormatter.ReadObject(Message message)
   at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
 
Additional Info:
 
MachineName : XXXXXX
TimeStamp : 4/30/2015 8:52:14 PM
FullName : Telerik.Sitefinity.Utilities, Version=8.0.5710.0, Culture=neutral, PublicKeyToken=b28c218413bdf563
AppDomainName : /LM/W3SVC/5/ROOT-1-130749005972998711
ThreadIdentity :
WindowsIdentity : NT AUTHORITY\NETWORK SERVICE
    Inner Exception
    ---------------
    Type : System.Xml.XmlException, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : End element 'root' from namespace '' expected. Found element 'Item' from namespace ''.
    Source : System.Runtime.Serialization
    Help link :
    LineNumber : 0
    LinePosition : 0
    SourceUri :
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Void ThrowXmlException(System.Xml.XmlDictionaryReader, System.String, System.String, System.String, System.String)
    HResult : -2146232000
    Stack Trace :    at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
       at System.Xml.XmlBaseReader.ReadEndElement()
       at System.Xml.XmlBaseReader.ReadElementContentAsString()
       at System.Runtime.Serialization.Json.JsonStringDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
       at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
       at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
       at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
 
 
 
Category: ErrorLog
 
Priority: 0
 
EventId: 90000
 
Severity: Error
 
Title:Enterprise Library Exception Handling
 
Machine: XXXXXX
 
App Domain: /LM/W3SVC/5/ROOT-1-130749005972998711
 
ProcessId: 2508
 
Process Name: c:\windows\system32\inetsrv\w3wp.exe
 
Thread Name:
 
Win32 ThreadId:11980
 
Extended Properties:
----------------------------------------

Posted by Community Admin on 01-May-2015 00:00

FYI... I submitted a ticket to Telerik.  If I get any answers I will post them back here in the forum.

This thread is closed