0

I want to change the Sort By (Default product sort order in the front end) option that is available in the Catalog -> Manage Categories -> Display Settings with a php script. I want to set that to position for all categories.

Is there a way to do that in both Magento 1 and 2 ?

Thanks in advance.

  • Found the answer for magento 2. $category->setDefaultSortBy('position'); $category->save(); – Shankar Thyagarajan Jul 31 '19 at 12:52
0

Best way to do change setting from System Configuration.

Magento has a system configuration field where you can set Default product sort order Position for all Category.

For magento2,Please go to admin Store>Configuration>Catalog>Catalog>StoreFrontend And Select your desire default sorting field from their and Save the configuration.

enter image description here

| improve this answer | |
  • Thanks. If I do this, will I be able to check that "Use config value" checkbox through code? – Shankar Thyagarajan Jul 24 '19 at 8:25
  • NO need. Check "Use config value" checkbox through code – Amit Bera Jul 24 '19 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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