Magento advanced profiles export - Prepend URL to IMAGE path

Magento advanced profiles export - Prepend URL to IMAGE path

September 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento advanced profiles export - Prepend URL to IMAGE path

Prepending URLs to Image Paths in Magento Advanced Export Profiles

Hello, fellow Magento developers! Today, we’re going to tackle an interesting challenge: prepending a URL value to one of the output columns in our advanced export profiles, specifically the image URL. We’ll append the URL to the beginning of the path output.

Understanding the Current Profile

Let’s first understand what’s happening in your current profile:

<!-- ... existing code ... -->

<action type="dataflow/convert_mapper_column" method="map">
    <var name="map">
        ...
        <map name="image">Image1</map>
        ...
    </var>
    <var name="_only_specified">true</var>
</action>

<!-- ... existing code ... -->

In this section, we map the “image” field to Image1. The issue here is that Image1 (which represents the image URL) doesn’t include the base URL. To fix this, we need to modify our mapping and add a bit of PHP.

Prepending the Base URL

To prepend the base URL, we’ll introduce a new field in our column map for the base URL and then concatenate it with the image path. Here’s how you can do it:

<!-- ... existing code ... -->

<action type="dataflow/convert_mapper_column" method="map">
    <var name="map">
        ...
        <!-- Add this new line -->
        <map name="base_url">base_url</map>
        <map name="image_path">Image1</map>
        <!-- Rest of the map remains the same -->

        <map name="image">${base_url}${image_path}</map>
    </var>
    <var name="_only_specified">true</var>
</action>

<!-- ... existing code ... -->

In this updated version:

  1. We’ve added a new field called base_url that maps to the global base_url variable.
  2. We’ve renamed your original image map to image_path.
  3. We create a new image mapping that concatenates the base_url and image_path.

The Final Touch

Don’t forget to include the necessary PHP opening and closing tags within your XML:

<!-- ... existing code ... -->

<action type="dataflow/convert_mapper_column" method="map">
    <var name="map">
        ...
        <?php $base_url = Mage::getBaseUrl(); ?>
        <!-- Add this new line -->
        <map name="base_url">${base_url}</map>
        <map name="image_path">Image1</map>
        <!-- Rest of the map remains the same -->

        <map name="image">${{base_url}${image_path}}</map>
    </var>
    <var name="_only_specified">true</var>
</action>

<!-- ... existing code ... -->

Conclusion

And there you have it! By following these steps, we’ve successfully prepended the base URL to our image paths in the Magento advanced export profile. Remember, maintaining clean and organized profiles is key for easy debugging and future modifications.

If you found this guide helpful, feel free to explore more Magento tips and tutorials on Laravel Company. Happy coding!

Originally published on Laravel Company

API Import/Export Errors

Our network