# Sort Category Listing by number of reviews

**URL:** <https://forum.shopware.com/t/sort-category-listing-by-number-of-reviews/50310>\
**Category:** International (English Only)\
**Tags:** general\
**Created:** [6. Januar 2018 um 17:52 UTC](https://forum.shopware.com/t/sort-category-listing-by-number-of-reviews/50310 "2018-01-06T17:52:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_S1](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Daniel\_S1](https://forum.shopware.com/u/Daniel_S1)\
**Post date:** [6. Januar 2018 um 17:52 UTC](https://forum.shopware.com/t/sort-category-listing-by-number-of-reviews/50310/1 "2018-01-06T17:52:27Z")

</div>

Hello everyone,

I have been trying to sort the category listing by number of reviews, I mean, if for example one of the products in the category listing has 10 reviews then it should appear first and then the ones with less reviews, 9, 8, 7 and so on. And if the product does not have reviews, then display the best seller.

Can someone explain me how to achieve that?

I was checking the code:

```
{foreach $sArticles as $sArticle}
  {include file="frontend/listing/box_article.tpl"}
{/foreach}

```

Trying to find a way to sort it but as I am new working with Shopware, didn’t have an idea.

Thanks in advance,

Daniel.

---

<div class="post-metadata">

**Author:** ![simkli](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/simkli/32/13124_2.png) [@simkli](https://forum.shopware.com/u/simkli)\
**Post date:** [6. Januar 2018 um 22:55 UTC](https://forum.shopware.com/t/sort-category-listing-by-number-of-reviews/50310/2 "2018-01-06T22:55:44Z")

</div>

Hi Daniel,

in the smarty&nbsp;template you only get one page of articles. So if you sort this array you would miss articles which might be on another&nbsp;page with a higher ranking. You need to extend the SearchBundle according to this tutorial:&nbsp;[https://developers.shopware.com/developers-guide/shopware-5-search-bundle/#list-of-conditions-and-sortings](https://developers.shopware.com/developers-guide/shopware-5-search-bundle/#list-of-conditions-and-sortings)

You need to add&nbsp;a new sorting =\> Add a new sorting and implement a sorting handler.

Best regards

---

<div class="post-metadata">

**Author:** ![Daniel\_S1](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Daniel\_S1](https://forum.shopware.com/u/Daniel_S1)\
**Post date:** [22. Januar 2018 um 17:20 UTC](https://forum.shopware.com/t/sort-category-listing-by-number-of-reviews/50310/3 "2018-01-22T17:20:02Z")

</div>

> [@simkli schrieb:](https://forum.shopware.com/profile/16741/simkli "simkli")
> 
> Hi Daniel,
> 
> in the smarty&nbsp;template you only get one page of articles. So if you sort this array you would miss articles which might be on another&nbsp;page with a higher ranking. You need to extend the SearchBundle according to this tutorial:&nbsp;[https://developers.shopware.com/developers-guide/shopware-5-search-bundle/#list-of-conditions-and-sortings](https://developers.shopware.com/developers-guide/shopware-5-search-bundle/#list-of-conditions-and-sortings)
> 
> You need to add&nbsp;a new sorting =\> Add a new sorting and implement a sorting handler.
> 
> Best regard

Thanks for your help simkli, the only problem I have is, that as I am new working with shopware, I don’t have idea how to proceed. Do you have a link where I can read about how to extend the SearchBundle for newbies?

---

<div class="post-metadata">

**Author:** ![simkli](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/simkli/32/13124_2.png) [@simkli](https://forum.shopware.com/u/simkli)\
**Post date:** [22. Januar 2018 um 17:55 UTC](https://forum.shopware.com/t/sort-category-listing-by-number-of-reviews/50310/4 "2018-01-22T17:55:52Z")

</div>

Hi Daniel,

first you should get the gist about

- the service cointainer&nbsp;[Service Container (Symfony 3.4 Docs)](https://symfony.com/doc/3.4/service_container.html)
- Denpendency Injection in Shopware&nbsp;[Best practices of Shopware plugin development](https://developers.shopware.com/blog/2015/11/11/best-practices-of-shopware-plugin-development/#dependency-injection)
- Services&nbsp;[Best practices of Shopware plugin development](https://developers.shopware.com/blog/2015/11/11/best-practices-of-shopware-plugin-development/#services)

Then you can read about["How to extend an existing service in shopware"](https://developers.shopware.com/developers-guide/shopware-5-core-service-extensions/).

I know it’s a lot to read but you need to know this in order to realize your idea. Otherwise you can contact a partner agency&nbsp;[https://en.shopware.com/partner/list](https://en.shopware.com/partner/list)

Best regards

&nbsp;
