Forums / Basic Configuration / Find/Replace Products_Url text

Find/Replace Products_Url text

Views: 1,383

Results 1 to 5 of 5
28 Feb 2011, 1:39 AM
#1
sparrowce avatar

sparrowce

Zen Follower

Join Date:
Feb 2011
Posts:
207
Plugin Contributions:
0

Find/Replace Products_Url text

I have been reading some discussions on find/replace using SQL and want to be sure I understand what I'm doing before implementing. I've backed up the database per this tutorial, https://www.zen-cart.com/tutorials/index.php?article=103, and copied website to FTP backup location.

I have unfortunately copy/pasted numerous urls into product listings (using the Bookshelf template) and discovered I failed to remove the http:// instead of just starting with www. I was correcting them one at a time but just learned how to go into the database side using phpMyAdmin, and though I am a ZenCart newbie, seeing the database behind the scenes really was exciting, because I am used to working with databases/data-tables and editing data directly in the tables, writing visual basic code to automate the databases and being able to export to Excel, import, etc. Very little MySQL experience, mostly Microsoft Access, Oracle, using SQL and Visual Basic in both, so seeing the database side really triggered a desire to learn more about how to get into the ZenCart tables and work with them better.

This discussion http://www.zen-cart.com/forum/showthread.php?t=124425 sounds like what I'm needing to do, but want to make sure I have an understanding of how to find/replace in the exact field that's needed. For example, in the linked discussion, here is what seemed to be the solution:

UPDATE products_description SET products_description = REPLACE(products_description, 'hematite', 'magnatite');

It appears the field name I need to find/replace in mine is products_url. How would I modify above and what is the difference between Tools/Install SQL Patches and selecting the SQL tab within the database where it seems you can select the field name from dropdown.

My guess would be something like this, but would appreciate a double check if I'm on the right track and how to implement.

UPDATE products_url SET products_url = REPLACE(products_url, 'http://www', 'www');

Any tips to help in understanding this side of things in general, and if I'm on the right track with the find/replace problem would be very appreciated, thank you so much.

Version 1.3.9

28 Feb 2011, 2:47 AM
#2
sparrowce avatar

sparrowce

Zen Follower

Join Date:
Feb 2011
Posts:
207
Plugin Contributions:
0

Re: Find/Replace Products_Url text

My guess was dead wrong! In Install SQL patches, got below error:

Failed: 1
Error ERROR: Cannot execute because table products_url does not exist. CHECK PREFIXES!
Warning Note: 1 statements ignored. See "upgrade_exceptions" table for additional details.

Any advice very much appreciated, I sure don't know what I'm doing, thank you!

28 Feb 2011, 10:28 AM
#3
pglad avatar

pglad

Zen Follower

Join Date:
Jun 2007
Posts:
198
Plugin Contributions:
0

Re: Find/Replace Products_Url text

I'm no expert in SQL so when I wanted to do something similar, I found the easiest option was to export the required table, saving it to your desktop as an SQL file, and then doing a simple find and replace using a text editor.

Before importing the changed SQL back into your database though you may to empty or delete the original otherwise it complains about duplicate entries.

2 Mar 2011, 2:38 AM
#4
sparrowce avatar

sparrowce

Zen Follower

Join Date:
Feb 2011
Posts:
207
Plugin Contributions:
0

Re: Find/Replace Products_Url text

Thank you, I just gave that a try, that works nice, thank you very much.
:smile:

2 Mar 2011, 9:31 AM
#5
pglad avatar

pglad

Zen Follower

Join Date:
Jun 2007
Posts:
198
Plugin Contributions:
0

Re: Find/Replace Products_Url text

Glad it worked for you :smile: