X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Useful: imagepaths after moving server (https://forum.x-cart.com/showthread.php?t=4959)

mikamedia 10-26-2003 11:58 PM

Useful: imagepaths after moving server
 
Hi,

I had to move one of our X-cart site to a new server. We use the filesystem to store images, not the database. I noticed that X-cart saves the whole path info for every image stored in the database.
I wrote a very small but useful script for anyone that wants to change the path info for all images at one time:

Code:

<?
mysql_connect('localhost', '%%username%%', '%%password%%');
$db = "%%dbasename%%";

Echo "Image paths will be changed for all images in X-cart...";

$selectPaths = mysql($db, "select * from xcart_thumbnails order by productid");
while ($rowPaths = mysql_fetch_row($selectPaths))
{
        $PathData = $rowPaths[2];
        echo "Old path: $rowPaths[2]
";
        $PathData = str_replace ("%%old_path_in_database%%", "%%new_path_in_database%%", $PathData);
        echo "New path: $PathData

";

        // write update to database
        mysql($db, "update xcart_thumbnails set image_path = '$PathData' WHERE productid = '$rowPaths[0]'");       

}
echo "

Done!";
?>


Replace all the %% %% with your own values.

It's not very handy to store the full path into the database, but it hope it helps for some people!

Good luck.
John.

funkydunk 10-28-2003 10:15 PM

Very useful. :)

cyberdriveway 08-23-2004 12:53 PM

Image path change xcart 4.0.2
 
I am only a couple of weeks into using x-cart. Tried to move the store to another location, and lost all of the image links. When I used the above code the "\"s were dropped from the path string during the update.

I was however able to make this sql statement work:

Code:

$sql= "UPDATE xcart_thumbnails SET image_path=( REPLACE (image_path,'dirA','dirB'))WHERE productid = '$rowPaths[0]';";
mysql_query($sql, yourconn);



dirA = original directory:
c:\inetpub\wwwroot\xcart\files\images.....

dirB = new directory:
c:\inetpub\wwwroot\backup\files\images....

Only include what needs to be changed:
(image_path, 'xcart', 'backup')


Hope this helps....


All times are GMT -8. The time now is 10:57 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.