Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » Product loop error in 9.8.0

Product loop error in 9.8.0

John Broers
Reply

Hi,

We use a product catalog for our product overview. On the template we use the following code to loop through the products:

var products = GetLoop("Products");
if (products.Count > 0)
{
    foreach (var product in products)
    {
        @if (!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product.ImageSmall.Default.Clean")))
        {
            <img src="@product.GetValue("Ecom:Product.ImageSmall.Default.Clean")" class="img-responsive" />
        }
    }
}

 

When i try to print just the product name it works fine, but as soon as i try to print the image or the TemplateTags i see the following error:

 

An error occurred while attaching module (Dynamicweb.Frontend.Content)

System.InvalidOperationException: Initialization has not completed yet.  The InitializationComplete method must be invoked before Dispose is invoked.
   at System.Runtime.Caching.ChangeMonitor.Dispose()
   at Dynamicweb.Caching.FileChangeMonitor..ctor(IEnumerable`1 paths)
   at Dynamicweb.Caching.MemoryCacheManager.ConvertCachePolicy(CacheItemPolicy policy)
   at Dynamicweb.Caching.MemoryCacheManager.Set(String key, Object cacheItem, CacheItemPolicy policy)
   at Dynamicweb.Ecommerce.Products.ProductImageService.FileExists(String filePath)
   at Dynamicweb.Ecommerce.Products.ProductImageService.GetProductImage(String imagePath, String imageSize)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderImagePatternItemShared(ImagePattern image, String imageFile, String productNumber, Template template, String tagPrefix)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderImagePatterns(IList`1 imagePatterns, Product product, Template template, String tagPrefix, ProductCatalogSettings paragraphSettings, Shop shop, RenderingContext renderingContext)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderProduct(Product product, Boolean extendedProperties, Template template, Int32 loopCounter, Boolean renderRelated, String productUrl, Int32 quantity, Int32 wishListId, Boolean renderPublicList, Boolean isRecursiveCall, Lazy`1 categoryFieldSorting, Int32 orderLineOfProductCount, RenderingContext renderingContext, String unitId)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderProducts(ProductCollection products, Template parentTemplate, String loopName, Int32 loopCounter, Boolean renderRelatedProducts, Boolean renderRelatedLists, Boolean isRecursive, RenderingContext renderingContext)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderProductsWithContext(ProductCollection products, Template parentTemplate, RenderingContext renderingContext)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderProducts(ProductCollection products)
   at Dynamicweb.Ecommerce.Frontend.Frontend.ListProducts(ProductCollection products, String groupsIdent, Boolean hasBeenSorted)
   at Dynamicweb.Ecommerce.Frontend.Frontend.List(String groups)
   at Dynamicweb.Ecommerce.Frontend.Frontend.EcomRender()
   at Dynamicweb.Ecommerce.Frontend.Frontend.GetContent()
   at Dynamicweb.Frontend.Content.GetModuleOutput(Paragraph paragraph, PageView pageview)


Replies

 
John Broers
Reply

Should have read the docs. I was still using the depricated Image Pattern feature

 
Nicolai Pedersen
Reply

Hi John

Well, the exception should probably not still be there...

Thanks for sharing your solution!

BR Nicolai

 
John Broers
Reply

If i understand the documentation correctly i would still be able to use '@product.GetValue("Ecom:Product.ImageSmall.Default.Clean")' in the product loop as long as i don't enable the improved images patterns. Is that correct?

I have both settings (in Settings > Ecommerce > Advanced configuration > Images) disabled but i still get the error i posted in my first post. Also i can't find the button 'Convert from deprecated image features' anywhere. For your information; i upgraded from 9.5.2 to 9.8.0.

 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply

Hi John,

To answer your question first. Yes, you should be able to use 'Ecom:Product.ImageSmall.Default.Clean' as long as you are using the old ImagePatterns or if you are using the Improved ImagePatterns in 'Compatibility mode'.

 

If I understand correctly, your settings look like the image below? 

Test

If the settings look like the image above, you should not see the button 'Convert from deprecated image features'. This button will only show up if you have set 'Deprecate Small, Medium and Large image features'.

Regarding the exception, it seems weird that you are getting this. What version of Dynamicweb.Caching do you have in your bin-folder?

Best regards,

Steffen

 
John Broers
Reply

Hi Steffen,

My settings are exactly like in your screenshot. 

I'm running version 2.1.0.0 of Dynamicweb.Caching.

 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply
This post has been marked as an answer

Hi John,

As far I can see, you should have version 2.2.2 of Dynamicweb.Caching, if you upgrade to 9.8.X. We have previously fixed a problem similar to yours, and that has been fixed in 2.2.2. So it could seem like there's some incorrect dlls in your bin-folder.

Best regards,

Steffen 

Votes for this answer: 1
 
John Broers
Reply

Hi Steffen,

That fixed the problem. Thank you!

 

 

You must be logged in to post in the forum