Add a sorting method in your Product List Page
This guide explains how to add a sorting criteria to your Product List Page (PLP).
Set an attribute as sortable
- Magento1
- Magento2
- Gezy
In Magento1 back office, navigate to Catalog > Attributes > Manage Attributes
.
In the list shown, find the attribute you want to set as sortable (i.e.
news_from_date
), and click on it. Scroll down to section
Frontend Properties
, and set Used for Sorting in Product Listing
to "Yes".
This feature is not supported for Magento2 yet. If your project requires this feature, please contact us.
This feature is not supported for Gezy yet. If your project requires this feature, please contact us.
Add sorting attribute in your theme
In order to add a new sorting attribute to your PLP, you can
theme/modules/Layer/LayerSorting/useOptions.js
like so:
import useDefaultOptions from "@front-commerce/theme/modules/Layer/LayerSorting/useOptions";
const useOptions = () => {
const defaultOptions = useDefaultOptions();
return {
...defaultOptions,
sortOptions: defaultOptions.sortOptions.concat([
{
label: "New",
value: "news_from_date",
},
]),
};
};
export default useOptions;
After these steps, you should be able to use your attribute to sort your PLP: