How to change user agent when downloading images on import

Images from one vendor cannot be imported via import function, here is a sample https://cdn.vegis.ro/images/products/img_201611250935/2380/full/sonnentor-ceai-boboci-de-trandafir-bio-30gr-101821.jpg , but it works to manually add the image on product or with wget user agent.

It seems like connection is not allowed (406 Not acceptable) ,I manually tried with wget command and got the error. How to change user agent when downloading the images from this vendor ? When using wget with user agent it works.

@CS-Cart_team can you please help me ? Today I got the third vendor that I cant work with because I cant download images for the same reason.

By default, CS-Cart does not specify any user agent when makes outgoing requests, like downloading images.

Please try to add:

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0');

before:

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 1);

in the app/Tygh/Http.php.

P.S. I haven’t tested it.

1 Like

Works perfectly, thank you ! Is it any problem if I leave it like this with your added line ?