mons/magento-toolbar-sorter

1.0.0 2023-02-05 03:46 UTC

This package is auto-updated.

Last update: 2024-12-28 05:18:09 UTC


README

Customize and optimize the default product listing sort by, include the direction in a single select element.

sort by screenshot

Installation

  1. Install module via composer composer require mons/magento-toolbar-sorter
  2. Register module php bin/magento setup:upgrade

Configuration

  1. Navigate to Stores > Attributes > Product
  2. Choose the sortable attribute you want to configure
  3. From the "Storefront Properties" tab, turn on the "Used for Sorting in Product Listing", then choose the behavior from "Product Listing Sorter" (see the options below)

Options

  • Default (do not override): use Magento's default sorting setting (normally ascending)
  • Ascending: show only the option for ascending (from low to high) order
  • Descending: show only the option for descending (from high to low) order
  • Ascending + Descending: show both the options above, ascending first
  • Descending + Ascending: show both the options, descending first

Theming

This module doesn't override the default template Magento_Catalog::product\list\toolbar\sorter.phtml, giving you the full control on it. Anyhow a working sample is provided as Mons_ToolbarSorter::product\list\toolbar\sorter.phtml.

Tested working with

  • Magento 2.4
  • PHP 8.1

Contribution

  • Fork this repository
  • Create your feature branch (git checkout -b feature/your-new-feature) or a bugfix branch (git checkout -b bugfix/bug-short-description) always from develop
  • Commit and submit a new Pull Request