Ecommerce Products Not Showing After Upgrade to 6.1
Hello,
I recently upgraded from SF 5.4.xxxx to 6.1.4300 and am
experiencing the issue noted in this breaking changes document. Can you
please provide me with more detail (step-by-step) on how I run this
script?
www.sitefinity.com/.../products-do-not-show-in-both-the-frontend-and-backend
Thank you,
Jim
UPDATE:
After posting, I found this in the forums --> http://www.sitefinity.com/developer-network/forums/bugs-issues-/sitefinity-6-1-upgrade---ecommerce-products-gives-error
I am developing in VB, so I had to convert the code to this -->
Imports System.Collections.GenericImports System.GlobalizationImports System.LinqImports Telerik.OpenAccessImports Telerik.Sitefinity.Ecommerce.Catalog.ModelImports Telerik.Sitefinity.Modules.Ecommerce.CatalogImports Telerik.Sitefinity.ServicesPublic Class EcomUpgradeFix Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load UpdateExistingProductsWithoutLifecycleSupport() Response.Write("All done!") End Sub Private Sub UpdateExistingProductsWithoutLifecycleSupport() Dim inactiveProducts As List(Of Guid) = CreateMasterProductsFromLiveOnes() PublishAllMasterProducts() UnpublishTheNotActiveProducts(inactiveProducts) End Sub Private Sub UnpublishTheNotActiveProducts(inactiveProducts As List(Of Guid)) Using catalogManager__1 = CatalogManager.GetManager() Dim products = catalogManager__1.GetProducts().Where(Function(p) p.Status = Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live) Dim skip As Integer = 0 Dim take As Integer = 100 Dim currentCount As Integer = 0 Dim totalCount As Integer = products.Count() While currentCount < totalCount Dim chunkedProducts = products.Skip(skip).Take(take) skip = skip + take currentCount = skip For Each productLive In chunkedProducts Try 'all inactive old versions should be made invisible. If inactiveProducts.Contains(productLive.OriginalContentId) Then Dim publishedTranslations = New List(Of String)(productLive.PublishedTranslations.ToList()) 'copy since the collection will be modified by the unpublish durring the loop If publishedTranslations.Count() > 0 Then 'unpublish for each translation For Each publishedTranslation In publishedTranslations catalogManager__1.Lifecycle.Unpublish(productLive, New CultureInfo(publishedTranslation)) catalogManager__1.Provider.FlushTransaction() Next Else 'unpublish invariant only catalogManager__1.Lifecycle.Unpublish(productLive, SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage) catalogManager__1.Provider.FlushTransaction() End If catalogManager__1.SaveChanges() End If Catch innerEx As Exception End Try Next End While End Using End Sub Private Sub PublishAllMasterProducts() Using catalogManager__1 = CatalogManager.GetManager() Dim products = catalogManager__1.GetProducts().Where(Function(p) p.Status = Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master) Dim skip As Integer = 0 Dim take As Integer = 100 Dim currentCount As Integer = 0 Dim totalCount As Integer = products.Count() While currentCount < totalCount Dim chunkedProducts = products.Skip(skip).Take(take) skip = skip + take currentCount = skip For Each productMaster In chunkedProducts Try Dim publishedTranslations = productMaster.PublishedTranslations If publishedTranslations.Count() > 0 Then 'publish for each translation For Each publishedTranslation In publishedTranslations catalogManager__1.Lifecycle.Publish(productMaster, New CultureInfo(publishedTranslation)) catalogManager__1.Provider.FlushTransaction() Next Else 'publish for default catalogManager__1.Lifecycle.Publish(productMaster, SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage) catalogManager__1.Provider.FlushTransaction() End If catalogManager__1.SaveChanges() Catch innerEx As Exception End Try Next End While End Using End Sub Private Function CreateMasterProductsFromLiveOnes() As List(Of Guid) Dim notActiveProducts As New List(Of Guid)() Dim currentUserId As Guid = Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId() Using catalogManager__1 = CatalogManager.GetManager() Dim products = catalogManager__1.GetProducts().Where(Function(p) p.Status = Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live AndAlso IsNothing(p.OriginalContentId)) ' yes it should be null not Guild.Empty For Each productLive As Product In products productLive.Status = Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master Dim isActiveLegacy = productLive.FieldValue(Of Boolean)("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 Not isActiveLegacy Then 'TODO use the internal method because the property IsActive now uses lifecycle notActiveProducts.Add(productLive.Id) productLive.ApprovalWorkflowState = "Unpublished" Else productLive.ApprovalWorkflowState = "Published" End If If currentUserId <> Guid.Empty Then productLive.Owner = currentUserId productLive.OriginalOwner = currentUserId End If Next catalogManager__1.SaveChanges() End Using Return notActiveProducts End FunctionEnd ClassUPDATE:
I got the script to run successfully, but the problem still exists. When I try to access the Products in the backend, I get the following error message: "Sequence contains no elements"
Thanks,
Jim
Hello Jim,
For projects using the Ecommerce it is required that the upgrade path is 5.4 - 6.0-6.1. This is due to the major changes to the Ecommerce module and products. Please, try upgrading again and if the issue persists, get back to us in a support ticket so we can investigate further and then we will share the solution with the community.
I'm still (a month after release) going back and forth with support...but tyr this..
Edit your product types table and...
The "ApplicationName" of your product type in DB is "/Catalog", but the system is looking for "/EcommerceCommon". Change this and you will see the products listed.
Sorry, nevermind...while it appears to work, the product.svc just outright crashed
...who cares though eh, customers don't need working (or supported) modules.