Developer forum

Forum » Integration » Up date multiple products from single source

Up date multiple products from single source

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

Is it possible to up date multiple products in Dynamicweb from a single source in an XML file? I have a catalog where we create unique products for each customer. So we can have something like this:

Product 1
    Number    1234
    ID              1234_CustomerId1

Product 2
    Number    1234
    ID              1234_CustomerId2


The products share the number but have an ID that is unique for a customer.

So far so good. However, I now have another source from a different system that doesn't know anything about a customer, and supplies data only for a product number, like this:

<?xml version="1.0" encoding="utf-8"?>
<tables>
  <table tableName="EcomProducts">
    <item table="EcomProducts">
      <column columnName="ProductNumber"><![CDATA[1234]]></column>
      <column columnName="ProductName"><![CDATA[My new name]]></column>
    </item>
  </table>
</tables>

I set up a task that takes this file as input, then set ProductNumber as the key in the hopes it would do something like this:

UP DATE EcomProducts SET Name = 'My new name' WHERE ProductNumber = '1234'

However, the batch fails with an error message about duplicate keys.

Is there any way to accomplish this?

Thanks,

Imar


Replies

 
Dmitriy Benyuk
Reply

Hi Imar,

can you specify what AddIn are you using for import data? And what is the destination provider?

Regards, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Dmitriy,

I am using the Data Integration node in the Management Center with an XML Source Provider and an Ecom target Provider.

Imar

 
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Imar,
could you change the destination provider and use the Dynamicweb Destination provider with the same key column selection?
The Ecom destination provider has a different logic and it is adding the ProductID column to the mapping even if it is not specified in the table column mapping and finds the first product with ProductNumber and sets it's id, and then in the update query it uses the sql statement with ProductID column to update, and fails on that.
I was using the Dynamicweb provider and it was working for me with reproducing the problem like in your case.
Regards, Dmitrij

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Great, I'll give that a try. Thanks.

I guess I'll be stuck with category fields though (using either provider) as that requires a poduct ID and not a number, correct?

Imar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Dmitrij,

Cool, that worked. It successfully updated multiple products with the new name.

Any suggestions on how to handle custom category fields?

Imar

 
Dmitriy Benyuk
Reply

Hi Imar,
So you need to import product category field values (table EcomProductCategoryFieldValue) and yes this requires the ProductID. Current EcomProvider finds the first product by the product number and uses its id, so it will not find the second/next products with the same product number. Do you need the same thing with updating multiple category filed values with product ids found by product number?
Regards, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Yes, that's what I am looking for.

Say I have this data:

Product 1
    Number    1234
    ID              1234_CustomerId1
    Category Field 1: True

Product 2
    Number    1234
    ID              1234_CustomerId2
    Category Field 1: True

I would then like to be able to update these two products with an XML that contains just the product number and a value for Category Field 1.

I think a solution similar to how addresses are mapped to a user by specifying what the actual key is would be great. Then I could specify the product number as my unique key which would then look up the associated product ID which in then uses to insert or update records in the ProductCategoryFieldValue table.

Does this make sense and sound reasonable?

Imar

 

roduct 1
    Number    1234
    ID              1234_CustomerId1

Product 2
    Number    1234
    ID              1234_CustomerId2

- See more at: http://developer.dynamicweb.com/forum/integration.aspx?ThreadID=41382#sthash.UQPdKxnK.dpuf

roduct 1
    Number    1234
    ID              1234_CustomerId1

Product 2
    Number    1234
    ID              1234_CustomerId2

- See more at: http://developer.dynamicweb.com/forum/integration.aspx?ThreadID=41382#sthash.UQPdKxnK.dpuf
 
Jonas Krarup Dam
Reply

Hi Imar,

I think I understand your scenario, and it sounds like you are bending the Ecommerce functionality a bit to suit your specific case.

As a rule, we try to avoid this kind of logic in the DynamicwebProvider, since it significantly slows performance to have to keep track of relationships and translate between selected keys and the "real" keys on the database, and the DynamicwebProvider is optimized for speed and direct access to the database.

Since your scenario is fairly specific to the solution you are working on, I don't think it makes sense to implement this as part to the standard functionality.

However, It should be fairly simple to implement a custom provider that can do this, if it inherits from the DynamicwebProvider - feel free to contact me if you would like pointers :-)

Alterntively, if you have patience, we have implemented row-level scripting for 8.7, as discussed here: http://developer.dynamicweb-cms.com/Default.aspx?ID=2&CategoryID=42&ThreadID=36789. That should make it simple for you to implement your required functionality as well.

Regards, Jonas

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Jonas,

I agree, that makes a lot of sense.

For the time being we solved it by using product fields instead of product category fields. Since product fields can be found based on the number we can easily find them.

Looking forward to the scripting capabilities in 8.7!

Thanks,

Imar

 

You must be logged in to post in the forum