0

Find the below code for your reference but it's showing both enable and disable products. I want to display only enable products.

    //Code for fetch products based on search term.    
    $this->_storeManager->setCurrentStore($storeid);
    $search_criteria = $this->searchCriteriaBuilder->create();
    $search_criteria->setRequestName("quick_search_container");
    $filter = $this->filterBuilder->setField('search_term')
            ->setValue($q)
            ->setConditionType("like")
            ->create();
    $filterGroup = $this->filterGroupBuilder->addFilter($filter)->create();
    $search_criteria->setFilterGroups([$filterGroup]);
    $search_result = $this->searchInterface->search($search_criteria);
    $totalSearchResults = $search_result->getTotalCount();
    $products = $search_result->getItems();

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.