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

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