Page 1 of 1

Extending service

Posted: Tue Aug 28, 2012 7:24 am
by broadleafer
My main menu has sub menus and the sub menus has other sub menus. So there are 3 menus in total and there are a total of 800 products. If the user selects a parent menu the site should list all the items under all it's child menu. Instead of listing all 800 items when the parent menu is selected, paging will be used and few items from each sub menu category will be displayed. Currently to display a child item when a parent menu is selected I have to include the item in the parent menu category and all the sub menu categories in broadleaf admin .

Will be a good idea to:
1) Extend the ProductSearchService which gets called in BroadleafCategoryController. Extending ProductSearchService means I will have to extend and create my own DatabaseProductSearchServiceImpl, CatelogServiceImpl and ProductDaoImpl classes. ProductDaoImpl is where the search logic will be implemented which will iterate through all the child categories and select some items from each category to be display ?
2) Just call the ProductDaoImpl.readFilteredActiveProductsByQuery method by passing it a HQL query ?
3) Add products to each category (parent category and to every single child category) in broadleaf admin ? This will take a lot of time and more chances of making a mistake.

Or is this something SOLR library can help me with ?

Re: Extending service

Posted: Tue Aug 28, 2012 9:43 am
by aazzolini
You should definitely update to M1-6 and make use of Solr, as this problem is already solved for you.

Once you update to M1-6, you might want to read this to become a little more familiar with our Solr implementation: http://docs.broadleafcommerce.org/curre ... earch.html

Here's a chunk from the rebuildIndex method:

Code: Select all

for (Category category : product.getAllParentCategories()) {
   document.addField("category", category.getId());
}


As you can see, that should solve your issue and you'll get all the benefits of running Solr.

Let me know if you run into any trouble.

Re: Extending service

Posted: Fri Aug 31, 2012 6:07 pm
by broadleafer
AWESOMEE !!. Do I have to update my pom.xml to get the M1-6 version of broadleaf library or do I have a grab a new copy of M1-6 Demo version ?

Would really like it if the M1-6 version was on Git so that I move my local branch to the newer version and grab the latest code.

Re: Extending service

Posted: Tue Sep 04, 2012 9:24 am
by aazzolini
Both Broadleaf and the DemoSite are on GitHub:

https://github.com/BroadleafCommerce/BroadleafCommerce
https://github.com/BroadleafCommerce/DemoSite

The reason the workspace isn't actually a git repository is to save space -- the repo adds about 70mb.

Advanced users can definitely clone the GitHub project and set up an upstream origin from us to stay up to date. Here's a more detailed guide:

http://docs.broadleafcommerce.org/curre ... Setup.html

You will need to update the broadleaf.version property in the parent pom.xml to reference M1-6. You will also need to make changes to your DemoSite project unfortunately. Here's a compare view of all of the changes. Note that you don't need all of these commits, but it should get you on your way should you choose to not start from a new clone. https://github.com/BroadleafCommerce/De ... 155c783eee