Jump to content

set hex of colour directly on the import csv combinations


Recommended Posts

Hi there,


can someone point me where I should hook my mod so I can import colours with


for example


who's in charge for that task? the AttributeGroup class? the Attribute class? the Combination class? I've looked in there and 


I can hack a quick sql query but I was wondering if there is a more elegant way to do it... and which class I should override.


that would be very handy for my purpose,

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

  • 1 month later...
  • 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...

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