Exemple #1
0
processor.process(categ_parent_map,
                  'data%sproduct.category.parent.csv' % os.sep, {
                      'worker': 1,
                      'batch_size': 5,
                      'model': 'product.category'
                  }, 'set')
processor.process(categ_map, 'data%sproduct.category.csv' % os.sep, {
    'worker': 1,
    'batch_size': 20
}, 'set')

# STEP 3 : Product Template mapping
template_map = {
    'id': mapper.m2o(TEMPLATE_PREFIX, 'ref'),
    'categ_id/id': mapper.m2o(CATEGORY_PREFIX, 'Sub Category'),
    'standard_price': mapper.num('cost'),
    'lst_price': mapper.num('public_price'),
    'default_code': mapper.val('ref'),
    'name': mapper.val('name'),
}
processor.process(template_map, 'data%sproduct.template.csv' % os.sep, {
    'worker': 4,
    'batch_size': 10,
    'context': context
}, 'set')

# STEP 4: Attribute List
attribute_list = ['Color', 'Gender', 'Size_H', 'Size_W']
attribue_value_mapping = {
    'id': mapper.m2o_att(ATTRIBUTE_VALUE_PREFIX, attribute_list),  # TODO
    'name': mapper.val_att(attribute_list),  # TODO
categ_map = {
    'id': mapper.m2o(CATEGORY_PREFIX, 'Sub Category'),
    'parent_id/id': mapper.m2o(CATEGORY_PREFIX, 'categoy'),
    'name': mapper.val('Sub Category'),
}

processor.process(categ_parent_map, 'data%sproduct.category.parent.csv' % os.sep,
                  {'worker': 1, 'batch_size': 5, 'model': 'product.category'}, 'set')
processor.process(categ_map, 'data%sproduct.category.csv' % os.sep, {'worker': 1, 'batch_size': 20}, 'set')

# STEP 3 : Product Template mapping
template_map = {
    'id': mapper.m2o(TEMPLATE_PREFIX, 'ref'),
    'categ_id/id': mapper.m2o(CATEGORY_PREFIX, 'Sub Category'),
    'standard_price': mapper.num('cost'),
    'lst_price': mapper.num('public_price'),
    'default_code': mapper.val('ref'),
    'name': mapper.val('name'),
}
processor.process(template_map, 'data%sproduct.template.csv' % os.sep,
                  {'worker': 4, 'batch_size': 10, 'context': context}, 'set')

# STEP 4: Attribute List
attribute_list = ['Color', 'Gender', 'Size_H', 'Size_W']
attribue_value_mapping = {
    'id': mapper.m2o_att(ATTRIBUTE_VALUE_PREFIX, attribute_list),  # TODO
    'name': mapper.val_att(attribute_list),  # TODO
    'attribute_id/id': mapper.m2o_att_name(ATTRIBUTE_PREFIX, attribute_list),
}