I need to sort my search results by product categories.
If I have Product A and Product B in Category A
And I have Product C and Product D in Category B
If all products are available in search result, I want to show them like,
Product A, Product B, Product C, Product D
I want to put same category products with each other on results page.
Currently It is showing as
Product A, Product C, Product B, Product D
I have tried this but its not working.
Best Answer
The reference you are using is not working is because there is no code to sort the products by category. You need to override Mage_CatalogSearch_Block_Result::_getProductCollection() and then add sorting function in it to show results in order of category id.
Try with below. Use the same reference and add this additional function to the same file.