I'm new to the Broadleaf Framework and experimenting with extending the Demo Site with some new features. Great architecture, I must say!
I do believe I stepped on a defect today, while disabling the SolrSearchService and defaulting to the DatabaseSearchService I was confronted with an obsolete Join in the ProductDaoImpl.
Code: Select all
@Override
public List<Product> readFilteredActiveProductsByCategory(Long categoryId, Date currentDate,
ProductSearchCriteria searchCriteria) {
// Set up the criteria query that specifies we want to return Products
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Product> criteria = builder.createQuery(Product.class);
// The root of our search is Category since we are browsing
Root<CategoryImpl> category = criteria.from(CategoryImpl.class);
// We want to filter on attributes from product and sku
Join<Category, Product> product = category.join("allProducts");
Join<Product, Sku> sku = product.join("defaultSku");
// Product objects are what we want back
criteria.select(product);
// We only want results from the determine category
List<Predicate> restrictions = new ArrayList<Predicate>();
restrictions.add(builder.equal(category.get("id"), categoryId));
attachProductSearchCriteria(searchCriteria, product, sku, restrictions);
attachActiveRestriction(currentDate, product, sku, restrictions);
attachOrderBy(searchCriteria, product, sku, criteria);
// Execute the query with the restrictions
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
return em.createQuery(criteria).getResultList();
}
The Join to 'allProducts' seems to be removed, and will return a "Unable to resolve attribute [allProducts] against path" when browsing through the front-end categories.
Not sure what the best approach would be to fix this?