If you manage a Magento 1 store with multiple store views, exporting manufacturer or brand names can become difficult when each store view uses different labels or translations.
For example, you may have an Arabic store view where manufacturer names are translated into Arabic, while the default store view uses English labels. In this situation, you may need to export only the manufacturer values assigned to a specific store view.
This guide explains how to export Magento 1 manufacturer attribute options to a CSV file while filtering the results by Store View.
Why Export Manufacturers by Store View?
Magento 1 stores commonly use product attributes such as Manufacturer, Brand, or Vendor to organize products.
When a store has multiple views, the same manufacturer option can have different labels depending on the selected store view. Exporting the values by store view can be useful for:
- Translating manufacturer or brand names.
- Auditing store-view-specific attribute labels.
- Preparing manufacturer data for migration.
- Comparing manufacturer names between store views.
- Cleaning up duplicate or outdated attribute options.
- Preparing CSV files for external systems or data processing.
Before You Run the Script
Before using the script, confirm the following:
- You are working with a Magento 1 installation.
- You have access to the Magento server files.
- You know the attribute ID of your Manufacturer attribute.
- You know the Store View ID that you want to export.
- The
var/exportdirectory exists and is writable by Magento/PHP. - You have a recent backup before making changes to production files.
Step 1: Find the Manufacturer Attribute ID
The script requires the EAV attribute ID for the manufacturer attribute.
You can check this from the Magento Admin Panel by navigating to:
Catalog → Attributes → Manage Attributes
Open your Manufacturer attribute and check its attribute information. Depending on your Magento setup, the attribute ID may also be available from the attribute URL or database.
In the example below, the attribute ID is 555. Replace this value with the ID from your own Magento installation.
Step 2: Find the Store View ID
Next, identify the store view from which you want to export the manufacturer labels.
For example, suppose your Magento installation has an Arabic store view with a Store ID of 7. The script can use that store ID to retrieve the corresponding manufacturer labels.
Always verify the Store View ID before running the export, especially if your Magento installation contains several websites, stores, and store views.
Magento 1 Manufacturer CSV Export Script
The following PHP script exports the manufacturer option ID and store-view-specific label to a CSV file:
<?php
require_once 'app/Mage.php';
Mage::app('admin');
$manufacturer_attribute_id = 555; // Change this to your Manufacturer attribute ID
$storeId = 7; // Change this to your required Store View ID
$collection = Mage::getResourceModel(
'eav/entity_attribute_option_collection'
)
->setAttributeFilter($manufacturer_attribute_id)
->setStoreFilter($storeId, false);
$exportPath = Mage::getBaseDir('var') . DS . 'export' . DS . 'manufacturers.csv';
$handle = fopen($exportPath, 'w');
if (!$handle) {
die('Unable to create the CSV file.');
}
$header = array('ID', 'Name');
fputcsv($handle, $header);
foreach ($collection as $manufacturer) {
$row = array(
$manufacturer->getOptionId(),
$manufacturer->getValue()
);
fputcsv($handle, $row);
}
fclose($handle);
echo 'Manufacturer CSV exported successfully: ' . $exportPath;
?>
How the Script Works
The script uses Magento's EAV option collection to retrieve the available values for the Manufacturer attribute.
1. Load Magento
require_once 'app/Mage.php';Mage::app('admin');
This loads the Magento application so that Magento models and resource collections can be used.
2. Specify the Manufacturer Attribute
$manufacturer_attribute_id = 555;
This tells Magento which EAV attribute's options should be exported. Replace 555 with your actual Manufacturer attribute ID.
3. Select the Store View
$storeId = 7;
This determines which store view should be used when retrieving the manufacturer labels.
This is particularly useful for multilingual Magento stores where the same manufacturer may have different labels in different store views.
4. Filter the Attribute Options
$collection = Mage::getResourceModel(
'eav/entity_attribute_option_collection'
)
->setAttributeFilter($manufacturer_attribute_id)
->setStoreFilter($storeId, false);
setAttributeFilter() limits the collection to the selected attribute, while setStoreFilter() applies the requested store-view context.
5. Create the CSV File
$exportPath = Mage::getBaseDir('var') . DS . 'export' . DS . 'manufacturers.csv';$handle = fopen($exportPath, 'w');
Instead of hard-coding the complete server path, Mage::getBaseDir('var') builds the path from the Magento installation directory.
The resulting file will be saved as:
var/export/manufacturers.csv
6. Add CSV Headers
$header = array('ID', 'Name');fputcsv($handle, $header);
The exported CSV contains two columns:
- ID: Magento's attribute option ID.
- Name: The manufacturer label returned for the selected store view.
7. Export Each Manufacturer
foreach ($collection as $manufacturer) {
$row = array(
$manufacturer->getOptionId(),
$manufacturer->getValue()
);
fputcsv($handle, $row);
}
The loop processes every manufacturer option and writes it to the CSV file.
Where Can You Find the Exported CSV?
After the script finishes successfully, navigate to your Magento installation's:
var/export/
You should find:
manufacturers.csv
You can open the file with Excel, Google Sheets, LibreOffice, or another CSV-compatible application.
Example CSV Output
The exported file will have a structure similar to this:
ID,Name12,Manufacturer A13,Manufacturer B14,Manufacturer C
For a multilingual store view, the Name column may contain the translated label associated with that store view.
Important: Store View Labels vs. Product Data
One important distinction is that this script exports attribute option labels. It does not export the products assigned to each manufacturer.
For example, if your Manufacturer attribute contains:
- Apple
- Samsung
- Sony
the script exports those attribute options and their labels. It does not automatically include product SKUs, product names, prices, stock levels, or product-to-manufacturer relationships.
If you need a complete manufacturer report containing products, SKUs, store-specific names, URLs, or other product attributes, a different product collection/export approach is required.
Common Problems and How to Fix Them
1. The CSV File Is Not Created
Check whether the var/export directory exists and whether PHP has permission to write to it.
You can also check the PHP error log and Magento logs for file-system or permission-related errors.
2. The Export Contains the Wrong Labels
Double-check the $storeId value. A wrong Store View ID can cause Magento to return labels from another store context.
3. Manufacturer Names Are Missing
Verify that the attribute ID is correct and that the Manufacturer attribute is configured as a dropdown/select attribute with options.
4. Arabic or Other Unicode Characters Look Incorrect
If the CSV contains Arabic, Urdu, or other non-Latin characters, the issue may be related to character encoding or how the CSV is opened by spreadsheet software.
If the data will be processed outside Magento, test the exported file with the target application before using it for a large migration or update.
5. Running the Script from the Wrong Location
The line:
require_once 'app/Mage.php';
assumes that the script is being executed from the Magento root directory or that the relative path correctly points to app/Mage.php.
If your script is located somewhere else, adjust the path accordingly.
Best Practices for Magento 1 Export Scripts
- Take a database and file backup before working on production Magento installations.
- Test the script on a staging environment first.
- Use the correct attribute and Store View IDs.
- Avoid placing temporary export scripts in publicly accessible locations.
- Remove or protect the script after completing the export.
- Do not expose Magento admin credentials or sensitive configuration data in export scripts.
- For large datasets, consider memory usage and execution-time limits.
- Verify the CSV contents before importing the file into another system.
When Should You Use a Custom Magento Export?
A custom export can be more useful than Magento's standard catalog export when you need specific data that is not available in the default export format.
For example, a custom Magento export can be designed to include:
- Store View-specific attribute labels.
- Product SKUs.
- Manufacturer IDs and names.
- Product URLs.
- Category information.
- Stock and pricing data.
- Custom product attributes.
- Multilingual product information.
- Data formatted for another application or migration.
Conclusion
Magento 1's EAV structure can make simple data exports more complicated, especially when multiple store views and translated attribute labels are involved.
The custom PHP script above provides a straightforward way to export Manufacturer attribute options for a specific store view into a CSV file. It can be useful for translation audits, catalog maintenance, data migration, and custom Magento reporting.
If your requirement goes beyond manufacturer options and you need product-level data, multilingual exports, custom fields, or automated Magento data processing, the export logic can be extended to match your specific store structure.
Frequently Asked Questions
Can I use this script with Magento 1.9?
Yes. The approach is designed for Magento 1 and uses Magento's EAV attribute option collection to retrieve Manufacturer values.
Can I export manufacturers from a specific Store View?
Yes. Set the appropriate Store View ID in the $storeId variable. The collection then uses that store context when retrieving the attribute option labels.
Does the script export manufacturer names or products?
The script exports Manufacturer attribute options. It does not export all products associated with those manufacturers.
Can I change the output filename?
Yes. Change manufacturers.csv in the $exportPath variable to the filename you need.
Can I export other Magento dropdown attributes?
Yes. The same general approach can be adapted for other select/dropdown EAV attributes. You need to replace the Manufacturer attribute ID with the ID of the attribute you want to export.
Can I export manufacturers from multiple Store Views?
Yes. You can run the export for different Store View IDs and save each result using a different filename, such as manufacturers-en.csv and manufacturers-ar.csv.
Why do I see different manufacturer labels between Store Views?
Magento supports store-specific attribute option labels. A manufacturer option can therefore display a different label depending on the active Store View.
Can this be automated?
Yes. For recurring exports, the script can be extended and executed through a scheduled server task such as cron, depending on your Magento environment and hosting configuration.
Can SCRIPTBAKER help with Magento 1 customization?
Yes. If your Magento store requires custom exports, legacy Magento maintenance, data migration, integrations, performance improvements, or custom development, SCRIPTBAKER can help assess the existing implementation and develop a solution around your requirements.
Last updated: