Hi,
We have a live solution where our customer is experience a weird bug where the visual editor shows an error on product slider, and i'm having some trouble finding the reason.
We're not experiencing the same problem on our development environment.
The error is:
The problem is that GetLastActiveProducts returns an emptylist... Here below i'v just hardcoded a random product id to fix the error.
​
There's plenty of active products on the shop, so i'm a bit confused why it's failing..
https://www.evasolo.com/da/products
Looking at the setup for product slider, i can't see a reason why this is even being run. Since im pretty sure the product is only used for the Details page.
The live site is Eva Solo - LIVE (9.14.1) (dynamicweb-cms.com)
and development is Login (Dynamicweb Cloud All-In-One - Business) (smartpage.dk)
And the page in question is here: (it's a custom template being used and the temporary fix with hardcoded product id is still there for now)
Hope you can help
Best regards,
Mikkel Hammer
Developer forum
E-mail notifications
Product slider error in Visual Editor
Replies
bump
Hi Mikkel
I cannot tell. That service call joins the product to ecomperiods and somehow that ends up null in your case... Probably some kind of data issue.
You can call productservice.GetAllProductKeys and take the first product from that and use instead.
Hi Nicolai,
Will try to look into the data issue.
But it looks like your suggested function is marked as internal in productService :/
Best regards,
Mikkel Hammer
Ah, good point!
You can attach a SQL profiler on the database and checkout the SQL that causes no records to be returned - and then find the data error from that.
BR Nicolai
Hi Nicolai,
Ebdrup and me have been on source code and data hunting and has found the issue!
Is it sort of a data issue and a lack of fallback if no valid product is found.
In the ProductRepository.GetLastActive there is a call to GetProductsBySql with a hardcoded "true" on doRefactoring.
Which calls ProductService.ReFactorProductList and then ends up in ProductService.CheckShowProductSettings where the issue is.
Since GetLastActiveProducts is called with a count of 1, and the products are fetched in GetProductsBySql before CheckShowProductSettings is called, the checks in that function can remove the product.
If the the product found fails one of these conditions, it is removed from the list, resulting in no product returned at all.
Where in our scenario it was the DontShowProductIfHasNoPrice that caused the issue.
But there is no fallback in GetLastActiveProducts to then find another product to guarantee that the count from the parameter is the amount of products returned.
We've changed the parameter in production to get 20 instead of 1 for now, and then hoping just one of those products pass the CheckShowProductSettings checks.
But we're hoping you can help us with a ​more permanent and "secure" solution.
Best regards,
Mikkel Hammer
You must be logged in to post in the forum