Change the “Sort By” option of a category with codeChange default category sort order by “in stock”Magento change sort order of selective categories in AdminHow to add custom category product position base on country and sort in Magento 1.9.x?MAGENTO - How to display the category details for editing?Magento2 : How to change sort by option position in sorting optionsChange category product sort order valuesMagento layered navigation attribute option sort by name not positionHow to restore 'sort by position' option for category sortinghow can i sort by using option value not option id value in listing page magento 2?Magento 2 - How to change Mega Menu sort order in store views alphabetical for each store view?

Are some indefinite integrals impossible to compute or just don't exist?

Error with uppercase in titlesec's label field

Applying for mortgage when living together but only one will be on the mortgage

How can flights operated by the same company have such different prices when marketed by another?

Accurately recalling the key - can everyone do it?

How is Sword Coast North governed?

Derivative is just speed of change?

Could flaps be raised upward to serve as spoilers / lift dumpers?

How can a class have multiple methods without breaking the single responsibility principle

The grades of the students in a class

Can I say "Gesundheit" if someone is coughing?

Gold Battle KoTH

What is the most 'environmentally friendly' way to learn to fly?

IBM mainframe classic executable file formats

What's the term for a group of people who enjoy literary works?

Conflict between senior and junior members

Best Ergonomic Design for a handheld ranged weapon

When did J.K. Rowling decide to make Harry and Ginny a couple?

Normally Closed Optoisolators

Please explain the difference in the order of naming Tzelafchad's daughters

Adding a (stair/baby) gate without facing walls

How to gracefully excuse yourself from a meeting due to emergencies such as a restroom break?

How to compare files with diffrent extensions and delete extra files?

How do I safety check that there is no light in Darkroom / Darkbag?



Change the “Sort By” option of a category with code


Change default category sort order by “in stock”Magento change sort order of selective categories in AdminHow to add custom category product position base on country and sort in Magento 1.9.x?MAGENTO - How to display the category details for editing?Magento2 : How to change sort by option position in sorting optionsChange category product sort order valuesMagento layered navigation attribute option sort by name not positionHow to restore 'sort by position' option for category sortinghow can i sort by using option value not option id value in listing page magento 2?Magento 2 - How to change Mega Menu sort order in store views alphabetical for each store view?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








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.










share|improve this question


























  • Found the answer for magento 2. $category->setDefaultSortBy('position'); $category->save();

    – Shankar Thyagarajan
    2 days ago


















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.










share|improve this question


























  • Found the answer for magento 2. $category->setDefaultSortBy('position'); $category->save();

    – Shankar Thyagarajan
    2 days ago














0












0








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.










share|improve this question
















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.







magento2 magento-1.9 category-products






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 23 at 11:27







Shankar Thyagarajan

















asked Jul 23 at 11:15









Shankar ThyagarajanShankar Thyagarajan

113 bronze badges




113 bronze badges















  • Found the answer for magento 2. $category->setDefaultSortBy('position'); $category->save();

    – Shankar Thyagarajan
    2 days ago


















  • Found the answer for magento 2. $category->setDefaultSortBy('position'); $category->save();

    – Shankar Thyagarajan
    2 days ago

















Found the answer for magento 2. $category->setDefaultSortBy('position'); $category->save();

– Shankar Thyagarajan
2 days ago






Found the answer for magento 2. $category->setDefaultSortBy('position'); $category->save();

– Shankar Thyagarajan
2 days ago











1 Answer
1






active

oldest

votes


















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






share|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 at 8:25











  • NO need. Check "Use config value" checkbox through code

    – Amit Bera
    Jul 24 at 8:58














Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f282998%2fchange-the-sort-by-option-of-a-category-with-code%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









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






share|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 at 8:25











  • NO need. Check "Use config value" checkbox through code

    – Amit Bera
    Jul 24 at 8:58
















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






share|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 at 8:25











  • NO need. Check "Use config value" checkbox through code

    – Amit Bera
    Jul 24 at 8:58














0












0








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






share|improve this answer













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







share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 23 at 11:50









Amit BeraAmit Bera

62.7k16 gold badges84 silver badges183 bronze badges




62.7k16 gold badges84 silver badges183 bronze badges















  • Thanks. If I do this, will I be able to check that "Use config value" checkbox through code?

    – Shankar Thyagarajan
    Jul 24 at 8:25











  • NO need. Check "Use config value" checkbox through code

    – Amit Bera
    Jul 24 at 8:58


















  • Thanks. If I do this, will I be able to check that "Use config value" checkbox through code?

    – Shankar Thyagarajan
    Jul 24 at 8:25











  • NO need. Check "Use config value" checkbox through code

    – Amit Bera
    Jul 24 at 8:58

















Thanks. If I do this, will I be able to check that "Use config value" checkbox through code?

– Shankar Thyagarajan
Jul 24 at 8:25





Thanks. If I do this, will I be able to check that "Use config value" checkbox through code?

– Shankar Thyagarajan
Jul 24 at 8:25













NO need. Check "Use config value" checkbox through code

– Amit Bera
Jul 24 at 8:58






NO need. Check "Use config value" checkbox through code

– Amit Bera
Jul 24 at 8:58


















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f282998%2fchange-the-sort-by-option-of-a-category-with-code%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form