Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with product limit on the search page #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Observer/SearchResultObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Magento\Framework\Event\ObserverInterface;

/**
* Observer for `controller_action_layout_render_before_catalogsearch_result_index'
* Observer for `catalog_product_collection_load_after'
*
* @see http://developer.matomo.org/guides/tracking-javascript-guide#internal-search-tracking
*/
Expand Down Expand Up @@ -59,6 +59,11 @@ class SearchResultObserver implements ObserverInterface
*/
protected $_view;

/**
* @var \Magento\Framework\App\Request\Http $request
*/
private $request;

/**
* Constructor
*
Expand All @@ -71,12 +76,14 @@ public function __construct(
\Chessio\Matomo\Model\Tracker $matomoTracker,
\Chessio\Matomo\Helper\Data $dataHelper,
\Magento\Search\Model\QueryFactory $queryFactory,
\Magento\Framework\App\ViewInterface $view
\Magento\Framework\App\ViewInterface $view,
\Magento\Framework\App\Request\Http $request
) {
$this->_matomoTracker = $matomoTracker;
$this->_dataHelper = $dataHelper;
$this->_queryFactory = $queryFactory;
$this->_view = $view;
$this->request = $request;
}

/**
Expand All @@ -88,6 +95,11 @@ public function __construct(
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
// Skip executes in case the current page isn't the search result page
if ($this->request->getFullActionName() !== 'catalogsearch_result_index') {
return $this;
}

if (!$this->_dataHelper->isTrackingEnabled()) {
return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion etc/frontend/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<observer name="matomo_observer"
instance="Chessio\Matomo\Observer\CheckoutSuccessObserver" />
</event>
<event name="controller_action_layout_render_before_catalogsearch_result_index">
<event name="catalog_product_collection_load_after">
<observer name="matomo_observer"
instance="Chessio\Matomo\Observer\SearchResultObserver" />
</event>
Expand Down