Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Order Categories and Subcategories by Name
 
duhdias
Jr. Member
 
Total Posts:  14
Joined:  2011-01-26
 

Hello,

I am developing an website who has more than 3000 categories/subcategories, and I need to sort this menu by name (not by position).

I tried some examples, but not solved, I am using Magento 1.7.0.2

How can I do this?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
duhdias
Jr. Member
 
Total Posts:  14
Joined:  2011-01-26
 
Monty22 - 28 May 2013 10:14 AM

Hi,

Check this http://www.paulwhippconsulting.com.au/webdevelopment/50-sorting-magento-categories-alphabetically-with-mysql

Hope this will help you!!

Thanks

Monty
iLoveMage

Thanks for your reply Monty22

I saw this before post here.
But I am trying to do this programmatically because it will have changes frequently.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Siggi_Schmitz
Enthusiast
 
Avatar
Total Posts:  811
Joined:  2011-07-03
 

Have a look in the file: app/code/core/Mage/Catalog/Block/Navigation.php and the functions renderCategoriesMenuHtml and _renderCategoriesMenuHtml.

There you can add a sort by name, for sure.

 
Magento Community Magento Community
Magento Community
Magento Community
 
duhdias
Jr. Member
 
Total Posts:  14
Joined:  2011-01-26
 
Siggi_Schmitz - 29 May 2013 01:33 AM

Have a look in the file: app/code/core/Mage/Catalog/Block/Navigation.php and the functions renderCategoriesMenuHtml and _renderCategoriesMenuHtml.

There you can add a sort by name, for sure.

Thanks for your reply.

I tried this:
http://eonsequeira.net/2012/03/21/sort-magento-top-menu-categories-by-name/#.Uaiql0CKKdI

The final code looked like this:
http://pastebin.com/p3cTFDib

But not worked yet…

 
Magento Community Magento Community
Magento Community
Magento Community
 
oneonesip
Jr. Member
 
Total Posts:  1
Joined:  2013-05-31
 

Hi, are there any information above tips not work for me, i just deploy for magento in cpanel. how could i edit it?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Siggi_Schmitz
Enthusiast
 
Avatar
Total Posts:  811
Joined:  2011-07-03
 
oneonesip - 31 May 2013 06:22 AM

Hi, are there any information above tips not work for me, i just deploy for magento in cpanel. how could i edit it?

What do you mean? You don`t have access to the files? No FTP access, for example?? oO

 
Magento Community Magento Community
Magento Community
Magento Community
 
duhdias
Jr. Member
 
Total Posts:  14
Joined:  2011-01-26
 
oneonesip - 31 May 2013 06:22 AM

Hi, are there any information above tips not work for me, i just deploy for magento in cpanel. how could i edit it?

You can use the file manager from cpanel and edit with it....

I couldn’t sort menu yet.
Anyone have any tips?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Blair Geddes
Jr. Member
 
Total Posts:  8
Joined:  2013-09-25
 

Any joy with a concrete solution for this? We’re looking to do too without mysql query having to be constantly ran every few weeks or.

Assuming simple sort by query in the relevant file should do it? Surprised it’s not a basic Magento feature to be honest.

 
Magento Community Magento Community
Magento Community
Magento Community
 
duhdias
Jr. Member
 
Total Posts:  14
Joined:  2011-01-26
 
Galaxy Stores - 01 October 2013 03:03 PM

Any joy with a concrete solution for this? We’re looking to do too without mysql query having to be constantly ran every few weeks or.

Assuming simple sort by query in the relevant file should do it? Surprised it’s not a basic Magento feature to be honest.

I solved my problem developing this code:

define('MAGENTO'realpath(dirname(__FILE__)));
require_once 
'app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); // Default or your store view name.

$resource Mage::getSingleton('core/resource');
$db_read $resource->getConnection('core_read');

$categorias = array();

$categories $db_read->fetchCol("SELECT ".$resource->getTableName("catalog_category_entity").".entity_id FROM ".$resource->getTableName("catalog_category_entity")." INNER JOIN ".$resource->getTableName("catalog_category_entity_varchar")." ON ".$resource->getTableName("catalog_category_entity").".entity_id = ".$resource->getTableName("catalog_category_entity_varchar").".entity_id WHERE ".$resource->getTableName("catalog_category_entity").".entity_id>2 AND ".$resource->getTableName("catalog_category_entity_varchar").".attribute_id=33 ORDER BY ".$resource->getTableName("catalog_category_entity_varchar").".value");

foreach (
$categories as $category_id{
    
try {
        $categorias[] 
Mage::getModel("catalog/category")->load($category_id);
    
catch (Exception $e{
        
echo $e->getMessage() . "\n";
    
}
}

$i 
0;
foreach (
$categorias as $row{
    $general[
'position'$i;
    
$row->addData($general);
    
$row->save();
    
$i++;
}

echo "All Categories and Subcategories ordered";
 
Magento Community Magento Community
Magento Community
Magento Community
 
Blair Geddes
Jr. Member
 
Total Posts:  8
Joined:  2013-09-25
 

Cool! Will try that. Assuming applied to this file?

app/code/core/Mage/Catalog/Block/Navigation.php

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top