Skip to content

Commit 0d27545

Browse files
committed
Fix issue with product limit on the search page
1 parent d3ae5fe commit 0d27545

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Observer/SearchResultObserver.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use Magento\Framework\Event\ObserverInterface;
2525

2626
/**
27-
* Observer for `controller_action_layout_render_before_catalogsearch_result_index'
27+
* Observer for `catalog_product_collection_load_after'
2828
*
2929
* @see http://developer.matomo.org/guides/tracking-javascript-guide#internal-search-tracking
3030
*/
@@ -59,6 +59,11 @@ class SearchResultObserver implements ObserverInterface
5959
*/
6060
protected $_view;
6161

62+
/**
63+
* @var \Magento\Framework\App\Request\Http $request
64+
*/
65+
private $request;
66+
6267
/**
6368
* Constructor
6469
*
@@ -71,12 +76,14 @@ public function __construct(
7176
\Chessio\Matomo\Model\Tracker $matomoTracker,
7277
\Chessio\Matomo\Helper\Data $dataHelper,
7378
\Magento\Search\Model\QueryFactory $queryFactory,
74-
\Magento\Framework\App\ViewInterface $view
79+
\Magento\Framework\App\ViewInterface $view,
80+
\Magento\Framework\App\Request\Http $request
7581
) {
7682
$this->_matomoTracker = $matomoTracker;
7783
$this->_dataHelper = $dataHelper;
7884
$this->_queryFactory = $queryFactory;
7985
$this->_view = $view;
86+
$this->request = $request;
8087
}
8188

8289
/**
@@ -88,6 +95,11 @@ public function __construct(
8895
*/
8996
public function execute(\Magento\Framework\Event\Observer $observer)
9097
{
98+
// Skip executes in case the current page isn't the search result page
99+
if ($this->request->getFullActionName() !== 'catalogsearch_result_index') {
100+
return $this;
101+
}
102+
91103
if (!$this->_dataHelper->isTrackingEnabled()) {
92104
return $this;
93105
}

etc/frontend/events.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<observer name="matomo_observer"
4747
instance="Chessio\Matomo\Observer\CheckoutSuccessObserver" />
4848
</event>
49-
<event name="controller_action_layout_render_before_catalogsearch_result_index">
49+
<event name="catalog_product_collection_load_after">
5050
<observer name="matomo_observer"
5151
instance="Chessio\Matomo\Observer\SearchResultObserver" />
5252
</event>

0 commit comments

Comments
 (0)