How to Sort the categories alphabetically?How to sort Product by it's parent category positionHow to add custom category product position base on country and sort in Magento 1.9.x?How to sort the Attribute Set list on the create new productAdd custom sort to sort products using name and price bothSort products by date DESC as the base sort order on category page?How to sort Response alphabetically in magento 1.9?Change category product sort order valuesHow to display categories in menu in the same order as in admin category tree?Sort Magento Topmenu (category name)Magento 2 :Sort Attributes Alphabetically in layered Navigation

Casting Goblin Matron with Plague Engineer on the battlefield

Double blind peer review when paper cites author's GitHub repo for code

Finish the Mastermind

How to realistically deal with a shield user?

Is it allowed and safe to carry a passenger / non-pilot in the front seat of a small general aviation airplane?

How to help new students accept function notation

Does bottle color affect mold growth?

Decode a variable-length quantity

Premier League simulation

How can I tell if a flight itinerary is fake

Is it really ~648.69 km/s Delta-V to "Land" on the Surface of the Sun?

Is TA-ing worth the opportunity cost?

Can an actual attack instead of a feint be used as the distraction for a help action?

Colleagues speaking another language and it impacts work

Is it double speak?

What does Fisher mean by this quote?

Look mom! I made my own (Base 10) numeral system!

Erratic behavior by an internal employee against an external employee

Is it true that control+alt+delete only became a thing because IBM would not build Bill Gates a computer with a task manager button?

Why use regularization instead of decreasing the model

Did WWII Japanese soldiers engage in cannibalism of their enemies?

What is the resistivity of copper at 3 kelvin?

How to explain to a team that the project they will work for 6 months will 100% fail?

How can glass marbles naturally occur in a desert?



How to Sort the categories alphabetically?


How to sort Product by it's parent category positionHow to add custom category product position base on country and sort in Magento 1.9.x?How to sort the Attribute Set list on the create new productAdd custom sort to sort products using name and price bothSort products by date DESC as the base sort order on category page?How to sort Response alphabetically in magento 1.9?Change category product sort order valuesHow to display categories in menu in the same order as in admin category tree?Sort Magento Topmenu (category name)Magento 2 :Sort Attributes Alphabetically in layered Navigation






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








0















enter image description here



How to Sort the categories alphabetically?










share|improve this question
























  • please try my answer's code once.

    – Balwant Singh
    Jul 29 at 10:31











  • Yes its working Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:58

















0















enter image description here



How to Sort the categories alphabetically?










share|improve this question
























  • please try my answer's code once.

    – Balwant Singh
    Jul 29 at 10:31











  • Yes its working Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:58













0












0








0








enter image description here



How to Sort the categories alphabetically?










share|improve this question














enter image description here



How to Sort the categories alphabetically?







sort






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 29 at 10:09









Junaid AshfaqJunaid Ashfaq

296 bronze badges




296 bronze badges















  • please try my answer's code once.

    – Balwant Singh
    Jul 29 at 10:31











  • Yes its working Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:58

















  • please try my answer's code once.

    – Balwant Singh
    Jul 29 at 10:31











  • Yes its working Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:58
















please try my answer's code once.

– Balwant Singh
Jul 29 at 10:31





please try my answer's code once.

– Balwant Singh
Jul 29 at 10:31













Yes its working Thanks :)

– Junaid Ashfaq
Jul 29 at 10:58





Yes its working Thanks :)

– Junaid Ashfaq
Jul 29 at 10:58










1 Answer
1






active

oldest

votes


















0














Try below code



Using Construct Method



protected $_categoryCollectionFactory;

public function __construct(
...

MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory,

...
)
...

$this->_categoryCollectionFactory = $categoryCollectionFactory;

...


public function getCategoryCollection()
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($collection as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';





Using Object manager



$objectManager = MagentoFrameworkAppObjectManager::getInstance();

// get the list of all categories
$categoryCollection = $objectManager->get('MagentoCatalogModelResourceModelCategoryCollectionFactory');
$categories = $categoryCollection->create();
$categories->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($categories as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';



I hope it will work...!!!






share|improve this answer



























  • yes its working for me Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:57






  • 2





    Please avoid direct use on object manager

    – Amit Bera
    Jul 29 at 11:00












  • i want to Sort the categories alphabetically except last one how it will do?

    – Junaid Ashfaq
    Jul 29 at 11:08











  • last will be at same position.

    – Junaid Ashfaq
    Jul 29 at 11:08











  • @JunaidAshfaq : if you find my answer is useful to you then please upvote the answer so it will help others people as well. Thanks :)

    – Balwant Singh
    Jul 30 at 5:36














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%2f283646%2fhow-to-sort-the-categories-alphabetically%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














Try below code



Using Construct Method



protected $_categoryCollectionFactory;

public function __construct(
...

MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory,

...
)
...

$this->_categoryCollectionFactory = $categoryCollectionFactory;

...


public function getCategoryCollection()
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($collection as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';





Using Object manager



$objectManager = MagentoFrameworkAppObjectManager::getInstance();

// get the list of all categories
$categoryCollection = $objectManager->get('MagentoCatalogModelResourceModelCategoryCollectionFactory');
$categories = $categoryCollection->create();
$categories->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($categories as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';



I hope it will work...!!!






share|improve this answer



























  • yes its working for me Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:57






  • 2





    Please avoid direct use on object manager

    – Amit Bera
    Jul 29 at 11:00












  • i want to Sort the categories alphabetically except last one how it will do?

    – Junaid Ashfaq
    Jul 29 at 11:08











  • last will be at same position.

    – Junaid Ashfaq
    Jul 29 at 11:08











  • @JunaidAshfaq : if you find my answer is useful to you then please upvote the answer so it will help others people as well. Thanks :)

    – Balwant Singh
    Jul 30 at 5:36
















0














Try below code



Using Construct Method



protected $_categoryCollectionFactory;

public function __construct(
...

MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory,

...
)
...

$this->_categoryCollectionFactory = $categoryCollectionFactory;

...


public function getCategoryCollection()
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($collection as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';





Using Object manager



$objectManager = MagentoFrameworkAppObjectManager::getInstance();

// get the list of all categories
$categoryCollection = $objectManager->get('MagentoCatalogModelResourceModelCategoryCollectionFactory');
$categories = $categoryCollection->create();
$categories->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($categories as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';



I hope it will work...!!!






share|improve this answer



























  • yes its working for me Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:57






  • 2





    Please avoid direct use on object manager

    – Amit Bera
    Jul 29 at 11:00












  • i want to Sort the categories alphabetically except last one how it will do?

    – Junaid Ashfaq
    Jul 29 at 11:08











  • last will be at same position.

    – Junaid Ashfaq
    Jul 29 at 11:08











  • @JunaidAshfaq : if you find my answer is useful to you then please upvote the answer so it will help others people as well. Thanks :)

    – Balwant Singh
    Jul 30 at 5:36














0












0








0







Try below code



Using Construct Method



protected $_categoryCollectionFactory;

public function __construct(
...

MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory,

...
)
...

$this->_categoryCollectionFactory = $categoryCollectionFactory;

...


public function getCategoryCollection()
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($collection as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';





Using Object manager



$objectManager = MagentoFrameworkAppObjectManager::getInstance();

// get the list of all categories
$categoryCollection = $objectManager->get('MagentoCatalogModelResourceModelCategoryCollectionFactory');
$categories = $categoryCollection->create();
$categories->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($categories as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';



I hope it will work...!!!






share|improve this answer















Try below code



Using Construct Method



protected $_categoryCollectionFactory;

public function __construct(
...

MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory,

...
)
...

$this->_categoryCollectionFactory = $categoryCollectionFactory;

...


public function getCategoryCollection()
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($collection as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';





Using Object manager



$objectManager = MagentoFrameworkAppObjectManager::getInstance();

// get the list of all categories
$categoryCollection = $objectManager->get('MagentoCatalogModelResourceModelCategoryCollectionFactory');
$categories = $categoryCollection->create();
$categories->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

foreach ($categories as $category)
echo $category->getId() . '<br />';
echo $category->getName() . '<br />';
echo $category->getUrl() . '<br />';



I hope it will work...!!!







share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 30 at 5:34

























answered Jul 29 at 10:29









Balwant SinghBalwant Singh

4341 gold badge3 silver badges16 bronze badges




4341 gold badge3 silver badges16 bronze badges















  • yes its working for me Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:57






  • 2





    Please avoid direct use on object manager

    – Amit Bera
    Jul 29 at 11:00












  • i want to Sort the categories alphabetically except last one how it will do?

    – Junaid Ashfaq
    Jul 29 at 11:08











  • last will be at same position.

    – Junaid Ashfaq
    Jul 29 at 11:08











  • @JunaidAshfaq : if you find my answer is useful to you then please upvote the answer so it will help others people as well. Thanks :)

    – Balwant Singh
    Jul 30 at 5:36


















  • yes its working for me Thanks :)

    – Junaid Ashfaq
    Jul 29 at 10:57






  • 2





    Please avoid direct use on object manager

    – Amit Bera
    Jul 29 at 11:00












  • i want to Sort the categories alphabetically except last one how it will do?

    – Junaid Ashfaq
    Jul 29 at 11:08











  • last will be at same position.

    – Junaid Ashfaq
    Jul 29 at 11:08











  • @JunaidAshfaq : if you find my answer is useful to you then please upvote the answer so it will help others people as well. Thanks :)

    – Balwant Singh
    Jul 30 at 5:36

















yes its working for me Thanks :)

– Junaid Ashfaq
Jul 29 at 10:57





yes its working for me Thanks :)

– Junaid Ashfaq
Jul 29 at 10:57




2




2





Please avoid direct use on object manager

– Amit Bera
Jul 29 at 11:00






Please avoid direct use on object manager

– Amit Bera
Jul 29 at 11:00














i want to Sort the categories alphabetically except last one how it will do?

– Junaid Ashfaq
Jul 29 at 11:08





i want to Sort the categories alphabetically except last one how it will do?

– Junaid Ashfaq
Jul 29 at 11:08













last will be at same position.

– Junaid Ashfaq
Jul 29 at 11:08





last will be at same position.

– Junaid Ashfaq
Jul 29 at 11:08













@JunaidAshfaq : if you find my answer is useful to you then please upvote the answer so it will help others people as well. Thanks :)

– Balwant Singh
Jul 30 at 5:36






@JunaidAshfaq : if you find my answer is useful to you then please upvote the answer so it will help others people as well. Thanks :)

– Balwant Singh
Jul 30 at 5:36


















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%2f283646%2fhow-to-sort-the-categories-alphabetically%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?