- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2021
12:32 AM
06-29-2021
12:32 AM
Re: Incorrect product count in layered navigation after overriding list product collection.
apply below solution to solve elastic search issue.
Spoiler
create di.xml file on path app/code/Namespace/Modulename/etc/frontend
<type name="Magento\Elasticsearch7\Model\Client\Elasticsearch"> <plugin name="elastcisearch_filter_plugin" type="Namespace\Modulename\Model\Plugin\ElasticLayerPlugin" /> </type>
Spoiler
Now we need to create "ElasticLayerPlugin.php" on path app/code/Namespace/Modulename/Model/Client
namespace Namespace\Modulename\Model\Plugin; class ElasticLayerPlugin { protected $helperObj; public function __construct( \Namespace\Modulename\Helper\Data $helperObj ) { $this->helperObj = $helperObj; } public function beforeQuery($subject,$query) { $productIds = $this->helperObj->filterCollectionIds(); // Add the product ids to filter the Elasticsearch product collection $query['body']['query']['bool']['filter'] = ['ids' => [ 'values' => $productIds]]; return [$query]; } }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2021
11:52 PM
12-26-2021
11:52 PM
Re: Incorrect product count in layered navigation after overriding list product collection.
Please update the code of the following helper file
\Namespace\Modulename\Helper\Data $helperObj
Thank you
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2022
02:49 PM
07-07-2022
02:49 PM
Re: Incorrect product count in layered navigation after overriding list product collection.
app/code/Vendor/Module/Helper/Data.php
<?php namespace Vendor\Module\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper { public $listProductBlock; public function __construct( Context $context, \Magento\Catalog\Block\Product\ListProduct $listProductBlock ) { $this->listProductBlock = $listProductBlock; parent::__construct($context); } public function filterCollectionIds(){ $productCollection = $this->listProductBlock->getLoadedProductCollection(); $productCollection->addAttributeToFilter('custom_attribute', array('eq' => "No")); $filteredIds = array(); foreach($productCollection as $product){ $productId = $product->getId(); $filteredIds[] = $productId; } return $filteredIds; } }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024
02:58 AM
12-04-2024
02:58 AM
Re: Incorrect product count in layered navigation after overriding list product collection.
Elasticsearch is deprecated now, and it's happeninig in 2.4 too. Is there any updated solution for this?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024
02:59 AM
12-04-2024
02:59 AM
Re: Incorrect product count in layered navigation after overriding list product collection.
Elasticsearch is deprecated now, and it's happening in 2.4 too. Is there any updated solution for this?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024
03:03 AM
12-04-2024
03:03 AM
Re: Incorrect product count in layered navigation after overriding list product collection.
That class does not exist on Magento 2.4.7 Is there a solution for the latest version?
- « Previous
-
- 1
- 2
- Next »