Search code examples
shopwareshopware6

How to get the import to follow redirects when importing images into Shopware 6?


When trying to import a CSV into Shopware 6 using the import/export function under Settings, the import does not work and gets stuck. But when I change the image URLs to their actual final URL, the import works fine and loads the images into the data.

(Changing all the URLs to their final URL is too time-consuming since there are over 20,000)

How to enable the follow redirects feature for when Shopware 6 downloads the images?


Solution

  • The context option follow_location and max_redirects are explicitly set to 0 when fetching a resource from a URL for a media file. I don't know the reasoning why redirects were explicitly disallowed in the FileFetcher but for such a minor change it might be ok to just patch the class to change the context options to 1 and something greater than 0 respectively.

    Update: I looked into it and it seems that the reason for the limitation are security concerns:

    It's possible to circumvent the url validator by simply redirecting to the attackers url.