Kriuchko
1/9/2019 - 10:45 AM

Search by category category search поиск по категориям

Magento 1 search by category

<form id="search_mini_form" class="search-form" action="<?php echo $this->helper('catalogsearch')->getResultUrl() ?>" method="get">
    <fieldset>
        <label for="search"><?php echo $this->__('SEARCH') ?></label>
        <?php $nav_class = new Mage_Catalog_Block_Navigation; ?>
        <?php foreach ($nav_class->getStoreCategories() as $_category):        
                if ($_category->getIsActive()): $li_class = ''; ?>
                <select id="search" name="cat">
                            <?php
                            if(method_exists($_category, 'getChildrenCategories')) 
                                $childrens = $_category->getChildrenCategories();
                            else 
                                $childrens = $_category->getChildren();
                            if($childrens && $childrens->count()): ?>
         
                                <?php foreach ($childrens as $children):?>
                                     <?php if ($children->getIsActive()):?>
                                        <option <?php if($_GET['cat'] == $children->getId()){ echo 'selected="selected"'; } ?> name="<?php print $this->htmlEscape($children->getName());?>" value="<?php print $children->getId();?>" ><?php print $this->htmlEscape($children->getName());?></option>
                                         
                                     <?php endif;?>                                          
                                <?php endforeach;?>                                            
    
                           <?php endif;?>   
                </select>                 
                <?php endif;?>
        <?php endforeach;?>  
        <div class="text">
            <input id="search" type="text" name="<?php echo $this->helper('catalogsearch')->getQueryParamName() ?>" value="<?php echo $this->helper('catalogsearch')->getEscapedQueryText() ?>" class="input-text" />
        </div>
        <input type="submit" class="submit" value="<?php echo $this->__('GO') ?>" />
        <div id="search_autocomplete" class="search-autocomplete"></div>
        <script type="text/javascript">
        //<![CDATA[
            var searchForm = new Varien.searchForm('search_mini_form', 'search', '<?php echo $this->__('') ?>');
            searchForm.initAutocomplete('<?php echo $this->helper('catalogsearch')->getSuggestUrl() ?>', 'search_autocomplete');
        //]]>
        </script>
    </fieldset>
</form>