Jump to content

import csv files of products in different languages : feature value not translated


julienmweb

Recommended Posts

I want to import csv files of products in 2 different languages in Prestashop 1.6. I have 2 csv files, one for each languages. Everything is fine when I import the csv file of the first language.


When I import the csv file of the second language, the features values are not understand by Prestashop as the translation of the features values of the first language, but added as new features values.


It s added as a new feature value because I use Multiple Feature module (http://addons.prestashop.com/en/search-filters-prestashop-modules/6356-multiple-features-assign-your-features-as-you-want.html) .


Without this module, the second csv import updates the feature value of both languages.


How can I make Prestashop understand that it s a translation, not a new feature value of a feature?


Thanks!


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

I found a solution by updating the database directly.

 

- I imported all my products using csv import in prestashop for the main language.

 

- feature values are stored in ps_feature_value_lang table. 3 columns : id_feature_value | id_lang | value

 

- In my case, french  is ps_feature_value_lang.id_lang = 1 and  english  ps_feature_value_lang.id_lang = 2

 

- Before I do any change, data of  ps_feature_value_lang looks like that: 

id_feature_value | id_lang | value

1                            | 1            | my value in french

1                            | 2            | my value in english

 

- I created a table (myTableOfFeatureValueIWantToImport) with 2 columns : feature_value_FR / feature_value_EN. I filled this table with data.

 

- because I don't know the ID (id_feature_value) of my feature values (prestashop has created these ID during the import of the csv file of my first language), I m gonna loop on the data of myTableOfFeatureValueIWantToImport and each time ps_feature_value_lang.id_lang == 2 and ps_feature_value_lang.value == "value I want to translate" I m gonna update ps_feature_value_lang.value with my feature values translated.

 $select = $connection>query("SELECT * FROM myTableOfFeatureValueIWantToImport GROUP BY feature_value_FR");
 $select->setFetchMode(PDO::FETCH_OBJ); 
while( $data = $select->fetch() )
      {  
          $valFR = $data->feature_value_FR;
          $valEN = $data->feature_value_EN;
          $req = $connection->prepare('UPDATE ps_feature_value_lang 
          SET ps_feature_value_lang.value = :valEN
          WHERE ps_feature_value_lang.id_lang = 2
          AND ps_feature_value_lang.value = :valFR
          ');
          $req->execute(array(
              'valEN' => $valEN,
              'valFR' => $valFR 
                )); 
      }
done  :D
Edited by julienmweb (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...