Magento Sort по специальной цене (отключенный продукт) на раскрывающемся панели страницы списка продуктов (toolbar.phtml)

magento.stackexchange https://magento.stackexchange.com/questions/5500

Вопрос

Я хочу расширить сортировку по раскрыванию по специальной цене или дисконтированному продукту с Toolbar.phtml

<div class="sort-by" style="float:left">
    <fieldset class="sort-by">
      <label><?php echo $this->__('Sort by') ?></label>
        <select onchange="setLocation(this.value)">
          <option value="<?php echo $this->getOrderUrl('price', 'asc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> Price - Low to High </option>
          <option value="<?php echo $this->getOrderUrl('price', 'desc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> Price - High to Low </option>
          <option value="<?php echo $this->getOrderUrl('name', 'asc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> Name - A to Z </option>
          <option value="<?php echo $this->getOrderUrl('name', 'desc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> Name - Z to A </option>
         <option value="<?php echo $this->getOrderUrl('update_at', 'desc') ?>"<?php if($this->isOrderCurrent('update_at') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>Newest First</option>
        </select>
  </fieldset>
</div>

Как я могу добавить еще один вариант для скидки, чтобы продукты были сортированы по специальной цене ASC?

Это было полезно?

Решение

Вам нужно только вставить заказ сортировки, и в коллекции уже должна быть специальная цена - добавьте это в свой <select>:

<option value="<?php echo $this->getOrderUrl('special_price', 'asc') ?>"<?php if($this->isOrderCurrent('special_price') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>Special Price</option>

Единственный недостаток в этом методе заключается в том, что он не будет фильтровать элементы из коллекции, которые в настоящее время не продаются, хотя он их сортирует.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top