If you manage a Magento 1 store with multiple store views, you may need to export category data for one specific store view. This is especially useful when each store view uses a different language, category name, or localized catalog structure.
For example, you may have an Arabic store view and want to export all active category IDs and their Arabic names into a CSV file. Instead of manually copying category data from the Magento Admin, you can use a small PHP script to generate the CSV automatically.
This guide explains how to export Magento 1 catalog categories for a specific store view, how the script works, where the CSV is saved, and what to check if the exported category names are incorrect or missing.
Why Export Categories by Store View?
Magento 1 supports multiple websites, stores, and store views. Category attributes such as the category name can have different values at the store-view level.
Exporting categories for a specific store view can be useful when you need to:
- Review translated category names.
- Audit localized catalog content.
- Compare category names between store views.
- Prepare category data for translation.
- Import or migrate catalog information.
- Check whether categories have the correct store-view values.
- Create a backup or working copy of category information.
- Perform SEO and content audits on localized category pages.
What This Script Exports
The example below exports two fields for each active category:
- ID: The Magento category ID.
- Name: The category name for the selected store view.
The result is saved as a CSV file inside Magento's var/export/ directory.
Before You Start
Before running the script, make sure you have:
- Access to the Magento 1 installation files.
- Permission to create and execute a PHP script.
- The correct store-view ID.
- Write permission for the
var/export/directory. - A backup or staging environment where possible.
Important: Magento 1 is end-of-life software. Avoid exposing custom scripts publicly or leaving export scripts accessible after use. Run the script in a controlled environment and remove it when the export is complete.
Step 1: Find the Magento Store View ID
First, identify the store view from which you want to export category names.
In the Magento Admin, go to:
System → Manage Stores
Under Store Views, locate the required store view and note its ID.
For example, suppose the Arabic store view has an ID of 7. We can use that value in the PHP script.
Step 2: Create the Export Script
Create a temporary PHP file in the Magento root directory. For example:
<?phprequire_once 'app/Mage.php';Mage::app('admin');$storeId = 7;$categories = Mage::getModel('catalog/category') ->getCollection() ->setStoreId($storeId) ->addFieldToFilter('is_active', 1) ->addAttributeToSelect('*');$exportDir = Mage::getBaseDir('var') . DS . 'export';if (!is_dir($exportDir)) { mkdir($exportDir, 0755, true);}$filePath = $exportDir . DS . 'categories_arabic.csv';$handle = fopen($filePath, 'w');if (!$handle) { die('Unable to create the CSV file.');}$header = array('ID', 'Name');fputcsv($handle, $header);foreach ($categories as $category) { $row = array( $category->getId(), $category->getName() ); fputcsv($handle, $row);}fclose($handle);echo 'Categories exported successfully to: ' . $filePath;
Step 3: Change the Store View ID
Find this line:
$storeId = 7;
Replace 7 with the ID of the store view you want to export.
For example:
$storeId = 3;
The script will then load category attribute values for store view ID 3.
Step 4: Choose the CSV Filename
You can also change the filename to make it easier to identify the exported store view.
$filePath = $exportDir . DS . 'categories_arabic.csv';
For example:
$filePath = $exportDir . DS . 'categories_french.csv';
This is particularly useful if you need to export categories for several store views.
Step 5: Run the Script
Run the PHP file using your normal controlled server environment. Depending on your hosting setup, this may be done through the command line or another secured execution method.
Once the script finishes successfully, it will create the CSV file inside:
var/export/
For the example above, the resulting file will be:
var/export/categories_arabic.csv
Example CSV Output
The generated CSV will contain data similar to:
ID,Name12,الملابس18,الأحذية25,الإكسسوارات31,الحقائب
The actual category names will depend on the values configured for the selected Magento store view.
How the Script Works
There are several important parts of the script worth understanding.
Loading Magento
require_once 'app/Mage.php';
This loads the Magento framework so the script can use Magento models, collections, configuration, and other core functionality.
Initializing Magento
Mage::app('admin');
This initializes the Magento application in the admin area so the script can access Magento's catalog data.
Selecting the Store View
->setStoreId($storeId)
This is the key part when exporting localized category information. It tells Magento which store view should be used when resolving store-scoped category attributes.
Loading Active Categories
->addFieldToFilter('is_active', 1)
This limits the export to active categories. If you also need inactive categories for an audit or migration, you can remove this filter.
Writing the CSV
fputcsv($handle, $row);
PHP's fputcsv() function handles CSV formatting and helps correctly separate values into columns.
Export Active and Inactive Categories
The current script exports only active categories. If you want to export every category, remove:
->addFieldToFilter('is_active', 1)
This can be useful when auditing a catalog because inactive categories may still contain valuable historical information.
Export the Category URL Key
If you are using the export for an SEO audit, category names alone may not be enough. You can also export the category URL key.
Change the header to:
$header = array('ID', 'Name', 'URL Key');
Then update the row:
$row = array( $category->getId(), $category->getName(), $category->getUrlKey());
This gives you a simple dataset for reviewing localized category URLs alongside their names.
Export More Category Information
You can extend the CSV when a larger catalog audit is required. For example, you could include:
- Category ID
- Category name
- URL key
- Parent category ID
- Is active status
- Category position
- Page title
- Meta description
- Meta keywords
For example, the header could be expanded to:
$header = array( 'ID', 'Name', 'URL Key', 'Parent ID', 'Is Active', 'Position', 'Page Title', 'Meta Description');
This approach is especially useful when the export is part of a technical SEO or international SEO audit.
Important Store-View Consideration
Magento category attributes can have different values at different scopes. A category may therefore have one name in the default store view and another name in an Arabic, French, German, or other localized store view.
When the goal is to audit localized catalog content, make sure you are using the correct store-view ID and that the relevant category attribute is configured to use store-view scope.
If the exported name unexpectedly matches the default store view, check the category attribute configuration and confirm that a store-specific value has actually been saved.
Common Problems and Solutions
1. The CSV File Is Not Created
Check whether the Magento var/export/ directory exists and whether the PHP process has permission to write to it.
The updated script also attempts to create the directory if it does not already exist.
2. Category Names Are Not Translated
First verify the store-view ID. Then check whether the category name has a store-specific value in Magento Admin.
If the localized value was never saved, Magento may return the default value instead.
3. The Script Returns a Magento Error
Check that the script is being executed from the correct Magento root directory and that app/Mage.php exists at the expected path.
4. The CSV Contains No Categories
Check whether the selected store view contains accessible categories and whether the active-category filter is excluding the categories you expected to see.
5. Arabic or Other Unicode Text Looks Incorrect
CSV encoding can become an issue when working with Arabic, Urdu, Chinese, or other non-Latin characters. If the file looks incorrect in spreadsheet software, verify the file encoding and how the application is importing the CSV.
For workflows involving multilingual catalogs, it is also worth validating the exported file in more than one application rather than assuming that an encoding problem means Magento returned incorrect data.
Security Considerations
A custom export script placed in the Magento root can expose catalog information if it is accessible through a public URL.
For that reason:
- Do not leave the script on a production server after the export.
- Use a protected environment whenever possible.
- Restrict access to the script.
- Do not expose sensitive catalog or customer information through custom exports.
- Remove temporary scripts after completing the task.
- Use a staging environment when practical.
When This Export Is Useful for SEO
A store-view category export can be more than a simple data backup. It can also support an international SEO audit.
For example, you can compare category names and URL keys across store views to identify:
- Missing translations.
- Duplicate or inconsistent category names.
- Unexpected default-language values.
- Inconsistent URL structures.
- Categories that are active in one store view but not another.
- Potential localization issues affecting category pages.
Once exported, the CSV can be combined with other SEO data such as page titles, meta descriptions, indexation information, internal links, and search performance to create a more complete category audit.
Conclusion
Exporting Magento 1 categories for a specific store view is straightforward with a small PHP script. By using Magento's category collection together with setStoreId(), you can retrieve category values for the store view you need and save them into a CSV file.
The same approach can also be extended to include URL keys, parent categories, positions, page titles, meta descriptions, and other catalog attributes, making it useful for catalog management, migration, localization, and SEO audits.
If you are working with a large or legacy Magento 1 installation, test custom scripts carefully and always protect or remove temporary export files and scripts after use.
Frequently Asked Questions
How do I export Magento 1 categories for a specific store view?
Load the Magento category collection and use setStoreId() with the required store-view ID. You can then loop through the collection and write the category data to a CSV file using PHP's fputcsv() function.
Where does the exported Magento category CSV file go?
In the example above, the CSV is saved inside Magento's var/export/ directory. The example filename is categories_arabic.csv.
Can I export categories from a different Magento store view?
Yes. Change the value of $storeId to the ID of the store view you want to export.
Can I export inactive Magento categories?
Yes. The example filters for active categories. Remove the is_active filter if you need both active and inactive categories.
Can I export category URLs as well as names?
Yes. You can add attributes such as url_key to the CSV output. This can be particularly useful for catalog and SEO audits.
Why am I getting the default category name instead of the translated name?
Verify that you are using the correct store-view ID and that the category name has a store-specific value. Also check the category attribute scope and confirm that the localized value has been saved for that store view.
Can this script export Magento category meta titles and descriptions?
Yes. Magento category collections can be used to retrieve additional category attributes such as page titles and meta descriptions, allowing you to create a more detailed SEO export.
Is this script suitable for a large Magento catalog?
It can work for smaller and moderately sized catalogs, but large catalogs may require additional optimization. For very large collections, consider processing records in batches and monitoring PHP memory usage and execution time.
Is Magento 1 still supported?
Magento 1 is legacy, end-of-life software. Existing Magento 1 stores should be handled carefully, particularly when adding custom scripts or making changes to production systems. Businesses running legacy Magento installations should also evaluate their long-term migration and security requirements.