Thursday, 23 June 2016

How Remove Position and Other attributes from Sort-By

(1) BY ADMIN PANEL:

Go to catalog->category

Select Category which you want to remove sort-by attributes

Select Display Setting

uncheck use all Available Attributes option

select attribute which you want to show in sort-by


(2) VIA CODING:

Navigate to the /app/design/frontend/default/your_theme/template/catalog/product/list/toolbar.phtml. Look at the bottom of the file, there will be code lines looks like the below

<?php echo $this->__('Sort by') ?> <select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
    <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> 
      selected="selected"<?php endif; ?>>
        <?php echo $_order ?>
    </option>
<?php endforeach; ?>
</select>
 
Just add an if statement like as the below code 
 
<?php echo $this->__('Sort by') ?> <select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
    <?php if ($_order != 'Position') : // Start Removing Sort By "Position" option from the list ?>
        <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> 
             selected="selected"<?php endif; ?>>
            <?php echo $_order ?>
        </option>
    <?php endif; // End Removing Sort By "Position" option from the list ?>
<?php endforeach; ?>
</select> 


No comments:

Post a Comment