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

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

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?