1

This question already has an answer here:

Replacing Core module search(form.mini). Run custom module search(form.mini) using javascript.

REF:[Replacing Core module javascript magento 2]

I don't know what mistake I did.

app\code\Custom\Search\etc

module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Custom_Search" setup_version="2.0.0">

    </module>
</config>

Custom\Search\view\frontend\requirejs-config.js

/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
(function(require){
(function() {
var config = {
    map: {
        '*': {
            'quickSearch':'Custom_Search/form.mini'
        }
    }
};

Custom\Search\view\frontend\layout\default.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header-wrapper">
            <block class="Custom\Search\View\Frontend\Templates" name="top.search" as="topSearch" template="form.mini.phtml" />
        </referenceContainer>

    </body>
</page>

Custom\Search\view\frontend\templates\form.mini.phtml

<?php
/**
 * Copyright © 2013-2017 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');
?>
<div class="block block-search">
    <div class="block block-title"><strong><?php /* @escapeNotVerified */ echo __('Search'); ?></strong></div>
    <div class="block block-content">
        <form class="form minisearch" id="search_mini_form" action="<?php /* @escapeNotVerified */ echo $helper->getResultUrl() ?>" method="get">
            <div class="field search">
                <label class="label" for="search" data-role="minisearch-label">
                    <span><?php /* @escapeNotVerified */ echo __('Search'); ?></span>
                </label>
                <div class="control">
                    <input id="search"
                           data-mage-init='{"quickSearch":{
                                "formSelector":"#search_mini_form",
                                "url":"<?php /* @escapeNotVerified */ echo $block->getUrl('search/ajax/suggest', ['_secure' => $block->getRequest()->isSecure()]); ?>",
                                "destinationSelector":"#search_autocomplete"}
                           }'
                           type="text"
                           name="<?php /* @escapeNotVerified */ echo $helper->getQueryParamName() ?>"
                           value="<?php /* @escapeNotVerified */ echo $helper->getEscapedQueryText() ?>"
                           placeholder="<?php /* @escapeNotVerified */ echo __('Search entire store here...'); ?>"
                           class="input-text"
                           maxlength="<?php /* @escapeNotVerified */ echo $helper->getMaxQueryLength();?>"
                           role="combobox"
                           aria-haspopup="false"
                           aria-autocomplete="both"
                           autocomplete="off"/>
                    <div id="search_autocomplete" class="search-autocomplete"></div>
                    <?php echo $block->getChildHtml() ?>
                </div>
            </div>
            <div class="actions">
                <button type="submit"
                        title="<?php echo $block->escapeHtml(__('Search')) ?>"
                        class="action search">
                    <span><?php /* @escapeNotVerified */ echo __('Search'); ?></span>
                </button>
            </div>
        </form>
    </div>
</div>

marked as duplicate by Community Nov 1 '17 at 6:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

I have develop module to replacing the core module search functionality.

please check below link for more information.

magento2-catalog-search-autocomplete

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