0

How to add new sorting in product listing page. I have frontend is PWA. So can you explain me how do that.

THANKS.

1 Answer 1

0

Magento 2.4

Sort product custom attribute

Create Custom Attribute with the below options values.

enter image description here

enter image description here

app/code/VendoreName/ModuleName/etc

schema.graphqls

input ProductAttributeSortInput {
  sample_attribute: SortEnum @doc(description: "Sort by the Product Custom Attribute.")
}

Run Magento Commands:

php bin/magento s:up
php bin/magento in:rein
php bin/magento s:s:d -f
php bin/magento c:c

For sort product data using custom attribute

{
  products(search: "bag", sort: {sample_attribute: DESC}) {
    items {
      name
      sku
      sample_attribute
    }
  }
}
7
  • Thanks for your answer but I want to sort new products. Apr 30, 2022 at 16:04
  • can you help me for that? May 2, 2022 at 11:18
  • You can use product entity_id like sample_attribute attribute.
    – Msquare
    May 2, 2022 at 14:59
  • Thanks. Can you explain me more. I really not understood. May 3, 2022 at 2:38
  • can you help me on this point because i have stuck on this point?. May 23, 2022 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.