Developer forum

Forum » Integration » Import products in several languages from BC

Import products in several languages from BC

Tomas Gomez
Reply

Hi,

We need to import the products from BC in several languages. The request is:

<GetEcomData><tables><Products type="all" setLanguage="LANG1" languages="ENU" /></tables></GetEcomData>

And the response is ok:

    <item table="EcomProducts">
      <column columnName="ProductID"><![CDATA[BCD-001]]></column>
      <column columnName="ProductLanguageID"><![CDATA[LANG1]]></column>
      <column columnName="ProductName"><![CDATA[BATA CIRUJANO SIMPLE TALLA ESTÁNDAR NO ESTÉRIL C/70UDS]]></column>
      ...
    </item>
    <item table="EcomProducts">
      <column columnName="ProductID"><![CDATA[BCD-001]]></column>
      <column columnName="ProductLanguageID"><![CDATA[ENU]]></column>
      <column columnName="ProductName"><![CDATA[SIMPLE SURGEON GOWN NON-STERILE STANDARD SIZE W/70 UNITS]]></column>
      ...

Now we map these data into DW by a Scheduled task that calls a Data integration job. This way, products with ProductLanguageID="LANG1" are mapped ok, but products with ProductLanguageID="ENU" are wrong as they should be integrated with ProductLanguageID="LANG2"

We are considering

  • Inside the Data integration job, to duplicate the table mappings and to filter them by "LANG1" or "ENU"
  • To create a new Scheduled task and a new Data integration job for LANG2

Is this the best way? What are your suggestions?

Regards,
Tomas


Replies

 
Michael Knudsen
Reply
This post has been marked as an answer

Hello Tomas,

- I haven't tried it myself, but wouldn't you specify all the languages in the request?  Assuming LANG1 is equal to DAN in BC.

<GetEcomData><tables><Products type="all" setLanguage="LANG1" languages="DAN,ENU" /></tables></GetEcomData>

Regarding the 'translation' of ENU to LANG2, I would apply a XSLT to the import job:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
        
<!-- copy all nodes and attributes -->
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="column[. = 'ENU']">
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            <xsl:value-of select="'LANG2'"/>
        </xsl:copy>
    </xsl:template>
</xsl:transform>

Br. Michael Knudsen

 

Votes for this answer: 1
 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Tomas,
yes, your idea #1 should work. Another way could be to import the languages from BC to Dynamicweb using <Languages type="all" />
request and then your language Ids from Dynamicweb will match the Language code form BC at the Product import so you will not need to have several same mappings.
BR, Dmitrij

Votes for this answer: 1
 
Tomas Gomez
Reply

Thanks Michael and Dmitrij for you viewpoints :-)

I think the XSLT method is cleaner, because to import the BC languages has more implications on the overall DW configuration.

I implemented the XSLT code. It compiles ok and the task has no errors, but the ENU/LANG2 products are not integrated.

What am I missing? Should that XSLT code be modified? Whats is needed to add?

Regards,
Tomas

 
Tomas Gomez
Reply

Oooops... my mistake!

I forgot to remap the Data integration job with the default languages (they were mapped to  "LANG1" constant)

It works really nice and clean :-)

Regards,
Tomas

 

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> and then your language Ids from Dynamicweb will match the Language code form BC

Working on a similar set up and wondering how would that work exactly. It seems that setLanguage is required so you can't fully let the ERP decide it. To make this work, should we set setLanguage to the ID of the primary language in the ERP?

Imar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Also, would it make sense to have setLanguage support multiple languages so you can do:

<Products type="all" setLanguage="LANG1,LANG2,LANG3"  languages="NLB,FRB,ENG" importProductProperties="true"  />

And make it optional so you can do this:

<Products type="all" languages="NLB,FRB,ENG" importProductProperties="true"  />

And get products back in NLB,FRB, and ENG?

Imar

 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,
yes, import languages first, set a default to the one that is also used in BC as default, then use it in the setLanguage attribute in the request,
so in the response you will just have the products in a default language from BC and products in the other languages if "languages" attribute is present.
BR, Dmitrij

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

No we can not skip "setLanguage" as it determines the output and the translations fidning in BC.
It can only skipped if the default language in BC is ENU.
Lets say you have NL as your default language in BC, then in your items translations you have items translated to languages: ENU, DAN.
The problem is that inside BC it is not possible to determine exactly what language is its default as they have changed the api inside its system codeunits so it always returns ENU
even if the company texts/items are in NL and installation is using NL version.
So if you will not specify setLanguage=NL in the request the codeunit will consider ENU as default language so you will lost the original default value in NL and get the output for just ENU and DAN (since NL value is considered as default which is "ENU" and then in the translation table there is a real value in ENU so it will be used instead)
So you need to specify it when the default language is not ENU and ENU is in the languages list

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I am still confused about this. What is the purpose of setlanguage and languages exactly?

I have a site with NLB (Belgian Dutch) as the default and French as a language. IN DW I have LANG1 and LANG2 (or I can make it LANG1 and FRB if needed.) In my little head, executing this (I know this won't work) would make the most sense:

<GetEcomData shopID="SHOP2">
  <tables>
    <Products type="all" setLanguage="LANG1,LANG2" languages="NLB,FRB" importProductProperties="true"/>
  </tables>
</GetEcomData>

To me, this would mean "fetch Belgian and French, and map them to LANG1 and LANG2. Make LANG1 the default as it's specified first.

However, even with just LANG1, things aren't working as expected. For example, when I execute this:

<GetEcomData shopID="SHOP2">
  <tables>
    <Products type="all" setLanguage="LANG1" languages="NLB,FRB" importProductProperties="true"/>
    <ProductGroups type="all" setLanguage="LANG1" languages="NLB,FRB"/>
    <Manufacturers type="all"/>
  </tables>
</GetEcomData>

I seem to be getting two records for each product back (LANG1 and FRB as expected) but three groups: LANG1, NLB and FRB.

Should this not be consistent? And should the groups not skip NLB as I also get that as LANG1 as the default?

I know I have asked this before, but man, what would it be helpful if we had some proper documentation and a guide on how to set this up, This site lists setLanguage on 6 pages where the one with the best explanation provides this description:

Defines the language of the imported data – use system language from NAV, i.e. the language you enter data in.

Right. Pretty non-descriptive and unhelpful, especially since it says it's "a country code" which it's not. So does this work as a filter on the NAV side to determine the primary language or does it just set the outgoing language ID for the product in the primary language? And same with languages: do I specify all languages I want or just the ones that are not the default?

For my concrete example described above, if my primary language in DW is LANG1 and it's NLB in the ERP and I also need to get French, what do I specify?

<GetEcomData shopID="SHOP2">
  <tables>
    <Products type="all" setLanguage="??" languages="??" importProductProperties="true"/>
    <ProductGroups type="all" setLanguage="??" languages="??"/>
    <Manufacturers type="all"/>
  </tables>
</GetEcomData>

Imar

 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Imar,
for your case the request needs to be this:

<GetEcomData shopID="SHOP2">
  <tables>
    <Products type="all" setLanguage="LANG1" languages="FRB" importProductProperties="true"/>
    <ProductGroups type="all" setLanguage="LANG1" languages="FRB"/>
    <Manufacturers type="all"/>
  </tables>
</GetEcomData>

But yes it looks like we should consider something better for this kind of a request, especially for the mappings.
BR, Dmitrij

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

Thanks Dmitrij, I am using that at the moment and that is working fine.

And yes, it would be nice if this could be made a bit more consistent and predictable. It takes a lot of trial and error every time we do a new integration project. Having better guidance and a more streamlined way of doing this will take a lot of frustration and time out of integration projects! :-)

Imar

 

You must be logged in to post in the forum