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.    
    $search_criteria = $this->searchCriteriaBuilder->create();
    $filter = $this->filterBuilder->setField('search_term')
    $filterGroup = $this->filterGroupBuilder->addFilter($filter)->create();
    $search_result = $this->searchInterface->search($search_criteria);
    $totalSearchResults = $search_result->getTotalCount();
    $products = $search_result->getItems();


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.