1

For filtering attributes, I have used the geturl() method. In order to get the required url, a client-side input type component should use in order to call the server and activate the required filtering via the defined controller. For attribute :

$items = $this->_filter->getItems();
    $filterValues = [];
    foreach ($items as $item) {
                   $filterValueData["filter_url"] = $item->getUrl();
}

How can this please be performed for a sorting attribute for example price or date ? I currently create those urls manually - for example : ?creation_date=asc

0

You'd take a look to Mage_Catalog_Block_Product_List_Toolbar

Sorter urls, in a default installation, use attribute codes, you can check this by calling

Mage::getSingleton('catalog/config')->getAttributeUsedForSortByArray();

Check catalog/product/list/toolbar.phtml, so you can see how Magento gets available orders, and their urls

    <div class="sort-by">
        <label><?php echo $this->__('Sort By') ?></label>
        <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 $this->__($_order) ?>
            </option>
        <?php endforeach; ?>
        </select>
        <?php if($this->getCurrentDirection() == 'desc'): ?>
            <a href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"><img src="<?php echo $this->getSkinUrl('images/i_desc_arrow.gif') ?>" alt="<?php echo $this->__('Set Ascending Direction') ?>" class="v-middle" /></a>
        <?php else: ?>
            <a href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"><img src="<?php echo $this->getSkinUrl('images/i_asc_arrow.gif') ?>" alt="<?php echo $this->__('Set Descending Direction') ?>" class="v-middle" /></a>
        <?php endif; ?>
    </div>
0

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.