Friday, May 17, 2013

Magento - Browse by Price Option in Left Navigation Using Custom Code

Here we mentioned about Browse By Price in the left nav. Price option incremented multiples of 1000

<?php
     
  

    $minPrice    =    Mage::getSingleton('catalog/layer')->setCurrentCategory(Mage::registry('current_category'))->getProductCollection()->getMinPrice();
    $maxPrice    =    Mage::getSingleton('catalog/layer')->setCurrentCategory(Mage::registry('current_category'))->getProductCollection()->getMaxPrice();
   
    if($maxPrice>0)
    {
    ?>
    <dl id="narrow-by-list">
      <dt>Browse By Price</dt>
      <dd>
        <ol class="m-filter-item-list ">
        <?php
            $incp=1;
            for($pi = $minPrice; $pi <= $maxPrice; $pi++)
            {
                if($incp>1)
                {
                    $minPrice    =    ($incp-1)*1000;
                    $pi         =    $incp*1000;
                    echo '<li><a href="'.$this->getUrl('catalogsearch/result/').'?q=a&price='.$incp.'%2C1000&search=cateinfo" title="$'.$minPrice.' - $'.$pi.'">$'.$minPrice.' - $'.$pi.'</a></li>';
                }
                else
                {       
                    $pi     =    $incp*1000;
                    echo '<li><a href="'.$this->getUrl('catalogsearch/result/').'?q=a&price=1%2C1000&search=cateinfo" title="$0 - $'.$pi.'">$0 - $'.$pi.'</a></li>';   
                }
                $incp++;
            }   
        ?>
       
         </ol>
      </dd>
    </dl>
        <hr/>
<?php }  ?>
   

By PHP with No comments

0 comments:

Post a Comment

    • Popular
    • Categories
    • Archives