1

Is it possible to turn off autocomplete or popular search terms? We have a few of these show up when you put in certain keywords and it just looks ugly.

enter image description here

1 Answer 1

2

I think there are multiple ways to do this. Override form.mini.phtml file and place it under Magento_Search/templates/form.mini.phtml in your current theme. file will contain below code.

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile
?>
<?php
/** @var $block \Magento\Framework\View\Element\Template */
/** @var $helper \Magento\Search\Helper\Data */
$helper = $this->helper(\Magento\Search\Helper\Data::class);
?>
<div class="block block-search">
    <div class="block block-title"><strong><?= /* @escapeNotVerified */ __('Search') ?></strong></div>
    <div class="block block-content">
        <form class="form minisearch" id="search_mini_form" action="<?= /* @escapeNotVerified */ $helper->getResultUrl() ?>" method="get">
            <div class="field search">
                <label class="label" for="search" data-role="minisearch-label">
                    <span><?= /* @escapeNotVerified */ __('Search') ?></span>
                </label>
                <div class="control">
                    <input id="search"
                           data-mage-init='{"quickSearch":{
                                "formSelector":"#search_mini_form",
                                "destinationSelector":"#search_autocomplete"}
                           }'
                           type="text"
                           name="<?= /* @escapeNotVerified */ $helper->getQueryParamName() ?>"
                           value="<?= /* @escapeNotVerified */ $helper->getEscapedQueryText() ?>"
                           placeholder="<?= /* @escapeNotVerified */ __('Search entire store here...') ?>"
                           class="input-text"
                           maxlength="<?= /* @escapeNotVerified */ $helper->getMaxQueryLength() ?>"
                           role="combobox"
                           aria-haspopup="false"
                           aria-autocomplete="both"
                           autocomplete="off"/>
                    <div id="search_autocomplete" class="search-autocomplete"></div>
                    <?= $block->getChildHtml() ?>
                </div>
            </div>
            <div class="actions">
                <button type="submit"
                        title="<?= $block->escapeHtml(__('Search')) ?>"
                        class="action search">
                    <span><?= /* @escapeNotVerified */ __('Search') ?></span>
                </button>
            </div>
        </form>
    </div>
</div>

I just removed ajax call. you can remove div element

<div id="search_autocomplete" class="search-autocomplete"></div>

But I think in this case you need to remove "destinationSelector":"#search_autocomplete" as well. You can remove data-mage-it attribute as well. which will completely disabled suggestions.

Let me know if any other help needed from my end.

1
  • Welcone @cz84. Can you please upvote as well. Commented Nov 8, 2018 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.