Page 1 of 1

Working with ShopBy in code

Posted: Wed Feb 25, 2015 4:52 am
by AbleMods
I spent some time this morning adapting the ShopBy mechanism directly into a custom category page. The site design doesn't permit the usual CategorySearchSidebar implementation, so I had some work cut out for me.

Overall it worked very nicely. You guys did a great job on it in my opinion. The code was organized and simple to work with in the UI layer.

My only remaining question has to do with the implementation of ShopBy filtering via ProductDataSource.AdvancedSearch() versus CatalogNodeDataSource.

In the past, it's been my practice to work with CatalogNodeDataSource to retrieve products when those products are going to be rendered. This is because only CatalogNodeDataSource returns the result set in the order specified in the admin. I specifically avoid using ProductDataSource for this reason.

My question is: Do ShopBy results via ProductDataSource.AdvancedSearch() return in Admin order by default? And is this going to create issues down-the-road as more people implement it for the purposes of rendering products and realize their admin sort order is no longer being respected?

Thoughts?

Re: Working with ShopBy in code

Posted: Thu Feb 26, 2015 2:42 am
by mazhar
AdvanceSearch renders items from multiple categories and I don't think so admin order will make any sense when rendering items from multiple categories. You can have different orders for different categories and when listing from both you can't consider them both.

Now that you asked this question it reminds me of something which came across when we were working with shop by navigation. This was to allow shopby navigation specifically for a single category which we need in some places where we don't use advance search. For example Category Grid (Shallow Item Display), this page is making use of ProductDataSource.LoadForCategory to list items from a specific category. Currently this display page doesn't work with shopby navigation due to some features incompatibility(search keyword I guess). But the good news is ProductDataSource.LoadForCategory has the ability to restrict over shopby choices if you pass them to it. So if you want to show products just from a single category and in admin order you may use this method to load products. Hopefully this will be helpful!

Re: Working with ShopBy in code

Posted: Thu Feb 26, 2015 3:49 am
by AbleMods
Thanks Mazhar, appreciate the insight.

I will take a look at LoadForCategory, I didn't notice it now accepts the ShopByChoices() collection.

Like I said, nicely done on the shop-by stuff. I know it was your first attack at the concept in Able. You implemented it very well considering how few schema changes were necessary.

This feature definitely adds substantial value to the software.