katrinamonarco Posted July 3, 2015 Share Posted July 3, 2015 i work on Os commerce and i face problem that How to change all image url in .csv file and show new url in website. i also put code to change url but how to change all url from .csv file. i have dropshiper and they give .csv file and in this .csv file all image url is same like this ""http://website/images/xctmpvfHmhD.png". code is like: $old_src = 'http://mywebsite.com/T/xctmpvfHmhD.png'; $old_url = 'http://mywebsite.com/T/'; $new_url = 'http://website.com/images/'; copy('http://mywebsite.com/T/xctmpvfHmhD.png''http://website.com/images/xctmpvfHmhD.png'); Link to comment Share on other sites More sharing options...
MrPhil Posted July 3, 2015 Share Posted July 3, 2015 If I understand you, you are being given a CSV file that contains image URLs which are incorrect for you. Are you using Easy Populate? One solution might be to build a "filter" that modifies the CSV file in a batch operation, and be run either on your PC or on your host server, before the CSV is used by Easy Populate. Another solution would be to modify Easy Populate's PHP code to modify the image URL field, say from /T/ to /image/, on the fly. Is that specifically what you were asking to do? If you know the URL field to change ($old_src), that shouldn't be too hard with a preg_replace() call. Link to comment Share on other sites More sharing options...
katrinamonarco Posted July 4, 2015 Author Share Posted July 4, 2015 i have many CSV file in that i have to change image url to $new_src. yes i know the $old_src and i change it to $new_src, so how can i use this preg_replace() function? No another way to change image url directly in CSV file? Link to comment Share on other sites More sharing options...
katrinamonarco Posted July 4, 2015 Author Share Posted July 4, 2015 i want to change images url in CSV file and that images is store in my folder and my folder images is call on website with changed image url. Link to comment Share on other sites More sharing options...
Dan Cole Posted July 4, 2015 Share Posted July 4, 2015 @@katrinamonarco You could probably do this as well using Excel or whatever spreadsheet you use, using a simple search and replace. Dan Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here. Link to comment Share on other sites More sharing options...
MrPhil Posted July 5, 2015 Share Posted July 5, 2015 If this is a fairly frequent update to the product database, I would think she'd want it as automated and hands-free as possible. http://php.net/manual/en/function.preg-replace.php has the details. It would be something like $new_src = preg_replace("#$old_url#", $new_url, $old_src); Link to comment Share on other sites More sharing options...
katrinamonarco Posted July 13, 2015 Author Share Posted July 13, 2015 I use this " $new_src = preg_replace("#$old_url#", $new_url, $old_src); " but still in .CSV file image URL is not change. I have some many image in CSV file so i change all IMAGE URL in .CSV file and that all images is store into a folder so what can i do? Link to comment Share on other sites More sharing options...
Dan Cole Posted July 13, 2015 Share Posted July 13, 2015 @@katrinamonarco If you managed to change the URL in the CSV file I assume that you can then import the CSV file as you have been (or if this is your first attempt to do so have a look the Easy Populate contribtion mentioned previously) and upload the images to the directory you changed the URL to. If you've done these things you should be good to go....after that, if it is still not working, tell us what the issue seems to be ie where you ended up and how you got there. Dan Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here. Link to comment Share on other sites More sharing options...
MrPhil Posted July 13, 2015 Share Posted July 13, 2015 I assume you're using Easy Populate to import the CSV file data and update your database. If not, what are you doing? The preg_replace() code would be a modification to the Easy Populate code -- after the line from the file has been read in and split up into fields, and before it starts modifying the database with those fields. Of course it would not modify the CSV file itself, only the data internally, on the fly. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.