【问题标题】:sort magento list page by price descending order按价格降序对 magento 列表页面进行排序
【发布时间】:2016-02-18 08:29:27
【问题描述】:

我正在使用 magento 版本。 1.9.2.3 .我正在尝试在列表页面中添加价格降序。我该怎么做?我尝试通过添加以下代码通过 local.xml 添加,但没有工作。任何帮助都是可观的......

<?xml version="1.0"?>
<layout version="0.1.0">
    <!-- Change default direction for simple searches -->
    <catalogsearch_result_index>
        <reference name="search_result_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
        </reference>
    </catalogsearch_result_index>

    <!-- Change default direction for advanced searches -->
    <catalogsearch_advanced_result>
        <reference name="search_result_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
        </reference>
    </catalogsearch_advanced_result>

    <!-- Change default direction for a category without layered navigation -->
    <catalog_category_default>
        <reference name="product_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
        </reference>
    </catalog_category_default>

    <!-- Change default direction for a category with layered navigation -->
    <catalog_category_layered>
        <reference name="product_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
        </reference>
    </catalog_category_layered>

    <!-- Change default direction for category with ID 3 -->
    <CATEGORY_3>
        <reference name="product_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>                                   
        </reference>
    </CATEGORY_3>
</layout>

【问题讨论】:

  • 你想在list.phtml中按价格降序自动排序吗?
  • 你检查过这个吗? inchoo.net/magento/… 或者您只想降价,所有过滤器怎么办,您想全部删除?
  • 我认为默认行为是价格升序我需要更改为降序
  • 然后试试这个教程我认为你的问题已经解决了并禁用 local.xml 以查看更改templatemonster.com/help/…

标签: sorting magento magento-1.9.1


【解决方案1】:

转到 /app/design/frontend/default/your-theme/template/catalog/product/list/toolbar.phtml 并找到

<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
    <?php echo $this->__($_order) ?>
</option>

替换

<?php if ($_order != 'Price'): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
    <?php echo $this->__($_order) ?>
</option>
<?php else: ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key) && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>
    <?php echo $this->__($_order) . ': Low to High' ?>
</option> 
<option value="<?php echo $this->getOrderUrl($_key, 'desc') ?>"<?php if($this->isOrderCurrent($_key) && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>
    <?php echo $this->__($_order) . ': High to Low' ?>
</option> 
<?php endif; ?>

别忘了清除缓存

【讨论】:

    猜你喜欢
    • 2013-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 2016-10-18
    • 2011-10-07
    • 2013-08-16
    相关资源
    最近更新 更多