Developer forum

Forum » PIM » Automatic family creation on import

Automatic family creation on import

Stephen Anthony Jackson
Reply

Can someone point me in the direction of

some documentation that shows how to automagically create family variants when important data?

i have a csv of products where the differing feature is volume and EAN.
 

I wish to import these creating a variant for each EAN, then display the products in the

frontend with the feature (volume) that distinguishes them. is this possible without manual work?

cheers

Steve


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Steve

Sure thing.

First you have to understand the data of product families - they are a version of Variants where the variant group has the VariantGroupFamily set to true.

See the data tables related to variants here:

https://doc.dynamicweb.com/documentation-9/ecommerce/product-catalog/variants#2840

Create a familiy in the backend and see how the data looks like. Look at the tables, EcomVariantGroup, EcomVariantGroupProductRelation, EcomVariantsOptions, EcomVariantsOptionsProductRelation

Then replicate that data in your import formats.

BR Nicolai

 
Stephen Anthony Jackson
Reply

Ok. So fix a few examples manually with the admin GUI, then export using the ECOM Provider for source, and then reproduce / re-import tables following the same pattern?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Yes, something like that :-)

 
Stephen Anthony Jackson
Reply

Actually I have since discovered that using a tablescript might be an even more elegant solution, cutting down the pre-processing required to craft special CSV files. Simply having a the variant name you want in a column and then specifying a tablescript to handle that column as a variant would be a more generic solution I think. The tablescript would do all the creates/lookups for variants and retrieve the correct ID's to join the product to said variant. Would this be a better way to go, Nicolai?  I'm surprised its not a standard feature in the data integration ("treat this column as a variant")

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Stephen,
to import a new variant to the existing product with variant options belonging to the family variant group you need to insert the data to those tables, see sample queries below:

insert into EcomVariantsOptions(VariantOptionId, VariantOptionLanguageId, VariantOptionGroupId, VariantOptionName) values('1234', 'LANG1', 'VARGRP9', 'EAN1234')
insert into EcomVariantOptionsProductRelation(VariantOptionsProductRelationProductId, VariantOptionsProductRelationVariantId) values ('PROD231362', '1234')
insert into EcomProducts(ProductId, ProductLanguageId, ProductVariantId, ProductNumber, ProductName, ProductDefaultShopId) values('PROD231362', 'LANG1', '1234', 'EAN1234', 'NAME for EAN1234', 'SHOP10')

then a new variant will be added and shown under the main product. Then you could make your source CSV files to match that tables data and try to import them using Dynamicweb as destination provider.
Its not very much clear what is your problem so if that doesn't help can you attach your source files or a part of it that you have problems to import.

BR, Dmitrij

 
Stephen Anthony Jackson
Reply

Hi Dimitri.

I want to try to normalize the table imports as much as possible so there is less need for a ton of business logic between the ERP and the CSV files. I figured that if I can make a tablescript which performs lookups on the EcomVariantOptions table (using the incoming fieldvalue that you put the tablescript onto), then you only need to import the EcomProducts.csv and the mapping of variants "VariantOptions" and "VariantOptionsProductRelations" will be performed by the table script itself.

Does that make any sense?

E.g CSV import file

ProductID, ProductName, EAN, Weight, Color

When performing mapping I specify the "VariantHandler" table script for both Weight and Color columns.

That script will then take the value of that rowcolumn, and do a "Select VariantOptionId from EcomVariantOptions where VariantOptionLanguageID = 'LANG1' and VariantOptionName = @rowcolumnvalue". 

Based on that result, I will either create a new entry for the incoming value and get the VariantOptionId or use the one retrieved in the select, and then add the relation to the product in EcomVariantOptionsProductRelation

Isnt that a good way to go, or do you see some disadvantages with this approach?

 
Stephen Anthony Jackson
Reply

Btw. The project I am working on is using the SAAS based offering from DW. Is it even allowed to have custom DLLs on the cloud offering I wonder?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Stephen

Yes - you can have custom dlls on your SAAS based projects. Contact the service desk to get access to that.

BR Nicolai

 

You must be logged in to post in the forum