Reputation: 33
I've played with this block a bit in toolbar.phtml:
<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, 'desc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select>
**<?php if($this->getCurrentDirection() == 'desc'): ?>**
<a class="category-desc v-middle" href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"><?php echo $this->__('Set Ascending Direction') ?></a>
<?php else: ?>
<a class="category-asc v-middle" href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"><?php echo $this->__('Set Descending Direction') ?></a>
<?php endif; ?>
</div>
I changed asc to desc, but it doesn't appear to be working.
Upvotes: 0
Views: 6016
Reputation: 2673
In catalog.xml add value:
<action method="setDefaultDirection"><dir>desc</dir></action>
example:
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
<!-- The following code shows how to set your own pager increments -->
<!-- .... -->
<action method="setDefaultDirection"><dir>desc</dir></action>
</block>
Upvotes: 0
Reputation: 10772
Magento currently doesn't let you define the sort order from the backend configuration. They let you choose what you can sort by, however. To change the default sort order, you must do the following:
Copy app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
to
app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php
Open app/code/local/Mage/Catalog/Product/Block/List/Toolbar.php
Look for protected $_direction = 'asc';
Change to protected $_direction = 'desc';
Save the file, clear caches.
To change the default sort by to Price, do the following:
In the Magento Admin, Go to System > Configuration > Catalog
Change Product Listing Sort by to Price
Click Save Config
Upvotes: 2