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;
How to Sort the categories alphabetically?
sort
add a comment |
How to Sort the categories alphabetically?
sort
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
add a comment |
How to Sort the categories alphabetically?
sort
How to Sort the categories alphabetically?
sort
sort
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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...!!!
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
|
show 1 more comment
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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...!!!
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
|
show 1 more comment
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...!!!
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
|
show 1 more comment
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...!!!
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...!!!
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
|
show 1 more comment
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
|
show 1 more comment
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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