InsideDarkWeb.com

Exclude child products from search in magento 2.3.2

I am trying to exclude child products from search. Say I have a bundle product B1 with ‘xyz’ name and it has a child with name ‘abc’. Now searching for ‘abc’ in frontend also gives the product B1 in search results.

What I need is If I search ‘abc’ then I should not get product B1 in the search results.
I have tried following solutions but they are related to magento 1

CatalogSearch – exclude child product names from fulltext

https://stackoverflow.com/questions/19907666/magento-search-result-excluding-tthe-child-products

In magento2.3.2 I did not find Mage_CatalogSearch_Model_Resource_Fulltext::_rebuildStoreIndex function.
ofcourse I looked for this inside vendor/magento/module-catalog-search/Model/ResourceModel/Fulltext.php

But I found a similar function that I felt is doing the reindexing part.function is next() It is located in

vendormagentomodule-catalog-searchModelIndexerFulltextActionIndexIterator.php

I tried commenting the following line as suggested in above solutions

// $productChildren = $this->productRelations[$productData['entity_id']];
    // if ($productChildren) {
        // foreach ($productChildren as $productChildId) {
            // if (isset($this->productAttributes[$productChildId])) {
                // $productChildAttr = $this->productAttributes[$productChildId];
                // if (!isset($productChildAttr[$this->status->getId()])
                    // || !in_array($productChildAttr[$this->status->getId()], $this->statusIds)
                // ) {
                    // continue;
                // }

                // $hasChildren = true;
                // $productIndex[$productChildId] = $productChildAttr;
            // }
        // }
    // }

cleaned cache, reindexed, but still getting results based on child products. Any suggestion how I can achieve this.

Magento Asked by Rajeev Singh on October 2, 2021

0 Answers

Add your own answers!

Related Questions

How to Special price based on attribute?

2  Asked on July 26, 2020 by user90560

     

is creating block within template in magento 2 good practice

0  Asked on July 24, 2020 by herve-tribouilloy

       

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.