Jump to content

SQL script that copies "product name" into "product code"


SkyHiRider

Recommended Posts

if its the same product and you wanna copy data from a field to another you can do a simple update script on the same table record, imagine your product id = 1 and the field "a" is the  field you wanna copy into field "b", do this,

 

update ps_product

set b=a

where product_id = 1

 

if you want to do for all the products in the table avoid the where statement.

 

Is this what do you want to do ??


 

Edited by nadie
Moderación del foro edita el mensaje: Quitado enlace de publicidad | Firma debe ir en la firma (see edit history)
Link to comment
Share on other sites

if its the same product and you wanna copy data from a field to another you can do a simple update script on the same table record, imagine your product id = 1 and the field "a" is the  field you wanna copy into field "b", do this,

 

update ps_product

set b=a

where product_id = 1

 

if you want to do for all the products in the table avoid the where statement.

 

Is this what do you want to do ??

 

 

http://www.prestashopconector.com

Yes, but I have no idea where the name and code are stored. I've had a quick look at the Ps erd but am not any wiser, as every text field is it's own entity due to the multilanguage  capabilities of PrestaShop.

Link to comment
Share on other sites

product name is stored in ps_product_lang table with rest of text information, as description, shor description, name etc... 

and products id, price, quantity and other foreing keys refered to the product (categories etc) are stored in ps_product table

 

so "product name" into "product reference" will be something like this:

 
 update ps_product p
join ps_product_lang pla 
on p.id_product = pla.id_product
 set p.reference = pla.name

 

 

if you are using multilanguage you have so many records in ps_product_lang as languages you have per each product,  so the relation between ps_product and ps_product_lang is 1 to many, so if you have diferent names for each product language you will need to chouse one as the reference, because reference is unique per product... add a where statement to filter which language you gonna use as the default for the reference information

Edited by nadie
Moderación del foro edita el mensaje: Quitado enlace de publicidad | Firma debe ir en la firma (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...