Jump to content

[SOLVED]Copying one language to all the others


Recommended Posts

Hi everyone,

I have been testing Prestashop for some time and I found a problem that I cannot solve. I created a lot of products by duplication of one single product, since they are all similar and I just have to change the picture, the name and the reference.

 

The problem is that if I duplicate the product and then I change the name of it, the change happens only in the primary language of the shop, so now I have a very big amount of items with different name in the main language, but same name in all the other languages (and it's impossible to correct the problem one by one, they're too many).

 

I found this old topic in these forums: http://www.prestasho...out-copy-paste/ and I think that the problem is nearly the same, but I tried the SQL query posted by rocky and it gave me this error:

 

#1136 - Column count doesn't match value count at row 1

 

I think the problem is that something has changed since the thread is about 1.4.x and I am using the lastest 1.5.4.1 version. The original query posted to copy everything from the english language (1) to french (2) is:

 

INSERT INTO `ps_product_lang` SELECT `id_product`, 2, `description`, `description_short`, `link_rewrite`, `meta_description`, `meta_keywords`, `meta_title`, `name`, `available_now`, `available_later` FROM `ps_product_lang` WHERE `id_lang` = 1

 

Thanks in advance to everyone who will try to help me :)

Edited by PascalVG (see edit history)
Link to comment
Share on other sites

Nabbolo, as you have the other languages already, you don't need to INSERT, but need to UPDATE records.

 

Please let me know what fields you want to copy exactly, so I can make some SQL statement for it.

 

Also, give a list of language ID's you want to copy TO, and the language ID that you want to copy FROM

(See Localization->Languages. Then look at first column (ID) for each language's ID)

 

pascal

  • Like 1
Link to comment
Share on other sites

Thanks for your quick reply :)

 

My goal is to copy FROM language 5 TO all the others enabled (so 1 to 4).

The only important field that I need to copy is the product name, since I think that it will be better to leave the descritpion empty for better SEO (it's not good to have the description in the same language in every language version).

 

The other problem that I have just noticed with duplication is that in the copied product, you can no longer modify the "reference" field (you change it, save, and the save doesn't have effect), you can only do it combination per combination: is this a desired behaviour or should it be considered a bug?

Edited by Nabbolo (see edit history)
Link to comment
Share on other sites

Hi Nabbolo,

 

- Go to your phpMyAdmin. Select ps_product_lang

- Make a backup of your table. (

-Run this sql statement:

 

UPDATE `ps_product_lang` a

INNER JOIN ( SELECT b.name, b.id_product, b.id_lang FROM `ps_product_lang` b WHERE b.id_lang=5) t ON

a.id_product = t.id_product AND a.id_lang != t.id_lang

SET a.name=t.name

 

Where 5 is the language you want to copy FROM

Summary what it does:

It updates all name fields of the records in ps_product_lang table, where the name fields get the value of those records with the same product_id but the one record that has the specified id_lang of 5.

 

(Actually, AND a.id_lang != t.id_lang

is not really necessary, but stops it from copying onto itself)

 

Hope this does the trick.

 

About the reference # No experience with this problem. Please make a new topic for this problem to get response from other forum people about this.

 

pascal

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

@Pascal: wow! You fixed it also for me! Thank you so much!

 

I used this code:

 

UPDATE `ps_product_lang` a
INNER JOIN ( SELECT b.name, b.id_product, b.id_lang FROM `ps_product_lang` b WHERE b.id_lang=7) t ON
a.id_product = t.id_product AND a.id_lang != t.id_lang
SET a.name=t.name

 

(it is from language 7).

But can you help me please with something else?

I want also to copy the link_rewrite FROM language 7 TO language 1.

 

How can i do that?

 

THANKYOU!

Link to comment
Share on other sites

I found it!

 

UPDATE `ps_product_lang` a
INNER JOIN ( SELECT b.link_rewrite, b.id_product, b.id_lang FROM `ps_product_lang` b WHERE b.id_lang=7) t ON
a.id_product = t.id_product AND a.id_lang != t.id_lang
SET a.link_rewrite=t.link_rewrite

Link to comment
Share on other sites

×
×
  • Create New...