2

Now I am working on magento-1.9.1. We all know Magento has default price filter. In stead of the default filter, I want to use a slider.

actual code: view.phtml,

<?php $_filters = $this->getFilters() ?>
 <?php foreach ($_filters as $_filter): ?>
    <?php if($_filter->getItemsCount()): ?>
        <dt><?php echo $this->__($_filter->getName()) ?></dt>
        <dd><?php echo $_filter->getHtml() ?></dd>
   <?php endif; ?>
 <?php endforeach; ?>

filter.phtml:

<ol>

<?php foreach ($this->getItems() as $_item): ?>

   <?php echo $_item->getLabel();?>
    <li>
        <?php if ($_item->getCount() > 0): ?>

            <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>">
                <?php echo $_item->getLabel() ?>
                <?php if ($this->shouldDisplayProductCount()): ?>
                <span class="count">(<?php echo $_item->getCount() ?>)</span>
                <?php endif; ?>
            </a>
        <?php else: ?>
            <span>
                <?php echo $_item->getLabel(); ?>
                <?php if ($this->shouldDisplayProductCount()): ?>
                    <span class="count">(<?php echo $_item->getCount() ?>)</span>
                <?php endif; ?>
            </span>
        <?php endif; ?>
    </li>
<?php endforeach ?>
</ol>

My code is, view.phtml:

<?php $_filters = $this->getFilters() ?>
                <?php foreach ($_filters as $_filter): ?>
                <?php
                            // get display attribute code
                            $attributeModel = $_filter->getAttributeModel();
                            if($attributeModel) {
                                $attr_code = $attributeModel->getAttributeCode();

                            }
                ?>

                <?php //echo $attr_code;?>
                <?php if($_filter->getItemsCount()): ?>
                    <?php if($attr_code == 'price'){?>
                        <dt><?php echo $this->__($_filter->getName()) ?></dt>
                        <dd>
                        <input id="range_1" type="text" name="range_1" value="1;<?php echo $maxPrice+100;?>" data-type="double" data-step="1" data-postfix="$" data-from="<?php echo $minPrice;?>" data-to="<?php echo $maxPrice;?>" data-hasgrid="true" />
                        </dd>

                    <?php }else { ?>
                    <dt><?php echo $this->__($_filter->getName()) ?></dt>
                    <dd><?php echo $_filter->getHtml() ?></dd>
                    <?php } ?>
                <?php endif; ?>
                <?php endforeach; ?>

my jquery is,

$j('#range_1').ionRangeSlider();

what I want is, the products should change when I change the price range in the slider. I don’t know how to give the filter URL to the slider. Please help me

2

First of all you need to catch the range of the ionRangeSlider(). By Using This Function you can catch the slider range

$j('#range_1').on("change", function () {
    var $this = $(this),
    from = $this.data("from"),
    to = $this.data("to");

console.log(from + " - " + to);
 });

Here from and to is the price range of the slider. Now replace console.log with

window.location('<?php echo $this->getUrl().'?price=from-to'?>') ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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