We have added couple of products on our Magento 2 site. In the home page of the site, we have a search form and there we have put input boxes as product name, from, to and location. We want to display the results as per the selected criteria in the form but its not working as expected.


<dd id="construction" class="item content active" data-role="content" >

                    <form method="GET" action="<?php echo $block->getUrl('catalogsearch/result/');?>">
                        <fieldset class="search-forms-fieldset" id="date-range-1">
                        <legend class="legend"><span><?= /* @escapeNotVerified */ __('Search Settings') ?></span></legend>

                        <div class="field region">
                            <label for="select" class="label"><span>Select</span></label>

                            <div class="control" id="conselect">
                                <input type="text" name="q" placeholder="<?= /* @escapeNotVerified */ __('What are you looking for?') ?>" />
                                <?php /*?><select name="looking" id="looking">
                                    <option value="">Please select</option>
                                    <option value="5">5</option>
                                    <option value="10">10</option>
                                    <option value="15">15</option>
                                    <option value="20">20</option>
                                </select><?php */?>
                        <div class="field">
                            <label for="location" class="label"><span><?= /* @escapeNotVerified */ __('Location') ?></span></label>

                            <div class="control" id="conlocation">
                                <input type="text" name="location" placeholder="<?= /* @escapeNotVerified */ __('Location') ?>" />

                        <div class="field">
                            <label for="available_from" class="label"><span><?= /* @escapeNotVerified */ __('Available From') ?></span></label>

                            <div class="control" id="confrom">
                                <input type="text" name="available_from" placeholder="<?= /* @escapeNotVerified */ __('Available From') ?>" id="date-from-1" />
                        <div class="field">
                            <label for="available_to" class="label"><span><?= /* @escapeNotVerified */ __('Location') ?></span></label>

                            <div class="control" id="conto">
                                <input type="text" name="available_to" placeholder="<?= /* @escapeNotVerified */ __('Available To') ?>" id="date-to-1"/>

                        <div class="actions-toolbar">
                          <div class="primary">
                            <button type="submit"
                                    class="action search primary"
                                    title="<?= $block->escapeHtml(__('Search')) ?>">
                                <span><?= /* @escapeNotVerified */ __('Search') ?></span>


Please see the below screenshot for your reference:

enter image description here

  • please check in stores -> attributes -> product on your attribute row searchable or use in search column is set to yes
    – Mohit Rane
    Jul 16, 2019 at 12:40
  • @MohitRane, I have checked and see the attribute is searchable
    – Siva
    Jul 16, 2019 at 12:58
  • @MohitRane, What others should I check?
    – Siva
    Jul 16, 2019 at 13:06
  • it should be working fine if it's searchable
    – Mohit Rane
    Jul 16, 2019 at 13:08
  • @MohitRane, Yes it should work but in my case it's not working as expected. I have posted the code. Can you check it and let me know where am i wrong?
    – Siva
    Jul 16, 2019 at 13:16

1 Answer 1


If you're using Elasticsearch, make sure there is a successful connection and your indexers are valid.

Stores > Configuration > Catalog > Catalog > Search > Search Engine

Make sure the products are in stock with quantity of 1 or greater, and visibility is Catalog, Search

Since this is custom code, verify that the extension is enabled. Sometimes running bin/magento cache:clean makes a difference.

Your Answer

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

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