Magento export all image url's

Magento export all image url's

August 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento export all image url's

Exporting All Product Images from Magento: A Comprehensive Guide

As an e-commerce developer, I often encounter clients who need to export their entire product catalog, including all associated images. While Magento provides robust data export functionality out-of-the-box, extracting all image URLs for each product requires a bit more finesse.

Understanding the Challenge

By default, when you export products from Magento using the built-in CSV Export feature or an extension like Export All Products Extensions, only the primary image URL is included in the exported data. Secondary and tertiary images are not captured.

The Easiest Solution: Use a 3rd Party Extension

If you’re looking for a quick fix, consider using an extension specifically designed to export all product images. Extensions like Advanced Product Exporter offer this functionality out-of-the-box.

To use it:

  1. Log in to your Magento admin panel.
  2. Navigate to the “System” > “Configuration” > “Advanced Product Importer”.
  3. Select the “Export Settings” tab.
  4. Choose the attributes you want to export, including “image_secondary”, “image_third”, etc.
  5. Click on “Export All Products”.

The extension will generate a CSV file containing all product data and their respective image URLs.

The Developer’s Approach: Customizing the Export Script

For those who prefer a more hands-on approach or want to avoid relying on third-party extensions, you can customize the default export script to include all image URLs. Here’s how:

  1. Navigate to app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php.
  2. Find the exportAction method.
  3. Inside the exportAction method, locate the following line:
    $collection = Mage::getModel('catalog/product')->getCollection();
    
  4. Replace it with this code:
    $collection = Mage::getResourceModel('catalog/product_collection');
    foreach ($collection as $_product) {
        $product = Mage::getModel('catalog/product')->load($_product->getId());
        if (count($product->getMediaGalleryImages()) > 0) {
            foreach ($product->getMediaGalleryImages() as $_image) {
                // Add the image URL to your export data
                $exportData[] = array(
                    'sku' => $product->getSku(),
                    'name' => $product->getName(),
                    'url' => Mage::helper('catalog/image')->init($product, 'image', $_image->getFile())
                                        ->resize(128)
                                        ->__toString()
                );
            }
        } else {
            // Add the main image URL to your export data
            $exportData[] = array(
                'sku' => $product->getSku(),
                'name' => $product->getName(),
                'url' => Mage::helper('catalog/image')->init($product, 'image')
                                        ->resize(128)
                                        ->__toString()
            );
        }
    }
    
  5. Save the file and clear your cache.

This customization modifies the default export script to retrieve all image URLs for each product using the getMediaGalleryImages() method, which returns an array of images associated with the product.

Best Practices and Considerations

  • Always backup your database before making any modifications to core files.
  • Test your changes in a staging environment before deploying them to production.
  • If you’re handling large datasets, consider optimizing your collection retrieval using pagination or partial loading to prevent memory exhaustion.

Conclusion

Exporting all product images from Magento is a common requirement for e-commerce websites. While third-party extensions offer quick solutions, customizing the export script provides more control and flexibility.

By following this guide, you can now successfully extract all image URLs for your products, enabling you to manage your product catalog more efficiently or integrate with external systems that require such data.

Remember, Magento is a powerful platform with numerous possibilities. Don’t hesitate to explore its capabilities further, and always consult the official documentation and resources available at laravelcompany.com.

Catalog Extensions Admin Configuration

Our network