# Infinite Scrolling Event

**URL:** https://forum.shopware.com/t/infinite-scrolling-event/54054
**Category:** International (English Only)
**Tags:** programming
**Created:** [13. Juli 2018 um 07:34 UTC](https://forum.shopware.com/t/infinite-scrolling-event/54054 "2018-07-13T07:34:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Tomasz](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Tomasz](https://forum.shopware.com/u/Tomasz)
#### Post date: [13. Juli 2018 um 07:34 UTC](https://forum.shopware.com/t/infinite-scrolling-event/54054/1 "2018-07-13T07:34:42Z")

</div>

Hello, I’m trying to change my Articles after Infinite Scrolling work. I need to find event that will handle it. I tried

```
 Enlight\_Controller\_Action\_PostDispatchSecure\_Widgets\_Listing

 Shopware\_Modules\_Articles\_sGetArticlesByCategory\_FilterResult

```

Enlight\_Controller\_Action\_Widgets\_Listing\_listingCount

But non of them work.&nbsp;

---

<div class="post-metadata">

### Author: ![odessite](https://avatars.discourse-cdn.com/v4/letter/o/f05b48/32.png) [@odessite](https://forum.shopware.com/u/odessite)
#### Post date: [13. Juli 2018 um 15:38 UTC](https://forum.shopware.com/t/infinite-scrolling-event/54054/2 "2018-07-13T15:38:37Z")

</div>

Can you provide your code?

Infinity scrolling invoked by url:

/widgets/Listing/ajaxListing?p=[pageNumber]&c=[categoryId]

So both of events subscribes should works for you:

Enlight\_Controller\_Action\_PostDispatchSecure\_Widgets\_Listing

Shopware\_Modules\_Articles\_sGetArticlesByCategory\_FilterResult

Is it possible that you haven’t reinstalled plugin after add these subscribers?

Try to assign some variable and check is it available on template or just die(); in event hendler:

```
_/\*\*_ _\*_ _@param_ _\Enlight\_Controller\_ActionEventArgs $args_ _\*_ _@return_ _bool_ _\*/_ **public function** postDispatchFrontendWidgets(\Enlight\_Controller\_ActionEventArgs $args) { $request = $args-\>getSubject()-\>Request(); $action = $args-\>getSubject(); $response = $action-\>Response(); $view = $action-\>View(); $assignData = $view-\>getAssign( **'articles'** ); $sArticles = $view-\>getAssign( **'sArticles'** ); **if** (!$request-\>isDispatched() || $response-\>isException() || !$view-\>hasTemplate() || ( **empty** ($assignData) && **empty** ($sArticles) ) ) { **return false** ; } $view-\>assign( **'myVariable'** , **'myValue'** ); }
```

---

<div class="post-metadata">

### Author: ![Tomasz](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Tomasz](https://forum.shopware.com/u/Tomasz)
#### Post date: [13. Juli 2018 um 17:15 UTC](https://forum.shopware.com/t/infinite-scrolling-event/54054/3 "2018-07-13T17:15:09Z")

</div>

It used to work but they changed controller from widgets/listing/ajaxListing to widgets/listing/listingCount. You can’t use $view-\>getAssign(‘sArticles’) because controller’s response is json.

```
 $this-\>Front()-\>Plugins()-\>ViewRenderer()-\>setNoRender(); $this-\>Response()-\>setBody(json\_encode($body)); $this-\>Response()-\>setHeader('Content-type', 'application/json', true);
```

---

<div class="post-metadata">

### Author: ![odessite](https://avatars.discourse-cdn.com/v4/letter/o/f05b48/32.png) [@odessite](https://forum.shopware.com/u/odessite)
#### Post date: [16. Juli 2018 um 15:03 UTC](https://forum.shopware.com/t/infinite-scrolling-event/54054/4 "2018-07-16T15:03:52Z")

</div>

Then you should replace data in body?

```
_/\*\*_ _\*_ _@param_ _\Enlight\_Controller\_ActionEventArgs $args_ _\*_ _@return_ _bool_ _\*/_ **public function** postDispatchFrontendWidgets(\Enlight\_Controller\_ActionEventArgs $args) { $action = $args-\>getSubject(); $response = $action-\>Response(); $body = _json\_decode_($response-\>getBody(), **true** ); **if** (! **empty** ($body)){ $body[**'totalCount'**] = 0; } $response-\>setBody(_json\_encode_($body)); }

```

&nbsp;
