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)
-   -   Copying title to meta (https://forum.x-cart.com/showthread.php?t=69057)

Dougrun 04-23-2014 12:22 PM

Copying title to meta
 
can anyone write me a SQL code that copies my product name into the title tag, meta keywords and meta description boxes so i dont have to go through 2000 product pages? I cant seem to find the tables they are stored in.

cherie 04-23-2014 05:33 PM

Re: Copying title to meta
 
Off the top of my head (untested), how about something like this:

UPDATE: This did not work
Code:


UPDATE xcart_products p
SET (title_tag, meta_keywords, meta_description) = (
  SELECT product, product, product
  FROM xcart_products_lng_en pl
  WHERE pl.productid = p.productid
);


Dougrun 04-24-2014 07:58 AM

Re: Copying title to meta
 
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(title_tag, meta_keywords, meta_description) = (
SELECT product, product, pro' at line 2

cherie 04-24-2014 08:20 AM

Re: Copying title to meta
 
Maybe something like this instead (untested):

UPDATE: This did not work (probably would for MSSQL)
Code:

UPDATE xcart_products p
SET
  title_tag = pl.product,
  meta_keywords = pl.product,
  meta_description = pl.product
FROM xcart_products_lng_en pl
WHERE pl.productid = p.productid
);


cflsystems 04-24-2014 10:36 AM

Re: Copying title to meta
 
In 4.6.x product name is NOT in products table so this will not work. Same for product's meta tags

They are all in product XX table - XX being language

cherie 04-24-2014 11:43 AM

Re: Copying title to meta
 
What won't work?

cflsystems 04-24-2014 12:19 PM

Re: Copying title to meta
 
The query won't work the way it is.

This

UPDATE xcart_products, xcart_products_lng_en SET xcart_products.title_tag = xcart_products_lng_en.product, xcart_products.meta_keywords = xcart_products_lng_en.product, xcart_products.meta_description = xcart_products_lng_en.product WHERE xcart_products.productid = xcart_products_lng_en.productid;

But make sure you backup first

cherie 04-24-2014 08:22 PM

Re: Copying title to meta
 
Thanks for clarifying. However, the query did not fail because of the location of the product name. Your implicit JOIN is interesting but not clear. I prefer this:
Code:

UPDATE xcart_products p JOIN xcart_products_lng_en pl ON pl.productid = p.productid
SET
  title_tag = pl.product,
  meta_keywords = pl.product,
  meta_description = pl.product


cflsystems 04-24-2014 09:37 PM

Re: Copying title to meta
 
Either way, as long as it works...


All times are GMT -8. The time now is 01:02 PM.

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