When I try to get a Product Collection within the IndexBuilderExtender for a ProductIndexBuilder it always returns a nullreference exception.
Even when I use the use the GetProductsBySql api method and verify the input sql string does return products when I directly query on the database.
We also ran into this problem during the technical sessions in Alkmaar last december (with Lars Hejgaard Sørensen), but didn't find a solution then.
Does anybody know how to solve this problem?
using Dynamicweb.eCommerce.Products;
var sql = $"SELECT * FROM EcomProducts WHERE ........"; <!-- RUNNING THIS SELECT ON THE DB RETURNS ROWS
var products = Product.GetProductBySql(sql); <-- THIS RETURNS A NULL REFERENCE EXCEPTION, WHY ???
var allProducts = Product.GetAllProducts(); <-- EVEN THIS RETURNS A NULL REFERENCE EXCEPTION, WHY ???