Jump to content

Adding hexadecimal color value to combinations_import.csv


Recommended Posts

Hi PrestaShop hackers!


This week i have been playing a lot with the import features that PrestaShop provides, super useful. But I was wondering, there exist an easy way to add the hexadecimal value for a color within the combinations_import.csv file? Currently, all the combinations from my testing side are imported right, but without the hexadecimal color value.


Thanks for your time and happy hacking!

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

  • 3 years later...

my own python code

import csv
field_names = ['color_name', 'hex']

start_id = 946

with open('colors_hex.csv', mode='r') as infile:
    reader = csv.reader(infile, delimiter=';')
    next(reader, None)  # skip the headers
    for i, rows in enumerate(reader):
      print("INSERT INTO `ps_attribute_lang` (`id_attribute`, `id_lang`, `name`) VALUES ('{1}', '1', '{0}'), ('{1}', '2', \"{0}\");".format(rows[0], i+start_id))
      print("INSERT INTO `ps_attribute` (`id_attribute`, `id_attribute_group`, `color`, `position`) VALUES ('{2}', '3', '{0}', '{1}');".format(rows[1], i, i+start_id))
      print("INSERT INTO `ps_attribute_shop` (`id_attribute`, `id_shop`) VALUES ('{0}', '1');".format(i+start_id))


Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...

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...