Developer forum

Forum » Integration » NAV Integration filtering products in xml query

NAV Integration filtering products in xml query

Jon Thorne
Jon Thorne
Reply

How would I be able to set a filter for xml queries to NAV for products (or customers)?

If there are 1000s of products in NAV, but I only want to retreive the products in a certain group or on a cutom field for use in DW is that possible?


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Jon,
That will require to use the Live integration extensibility points - notification subscribers.
So in order to filter out the products needed for the request you can subscribe to:
Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.ProductInfo.OnBeforeGenerateProductInfoXml
and update the Products property from the notification arguments.
You can also use the same subscriber to filter the products per current user/customer:
var user = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Helpers.GetCurrentExtranetUser();
If this user should not make a request for those products then update/clear the Products property.
BR, Dmitrij

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Also on the user edit page there is an option to disable the live prices for that user:

 
Jon Thorne
Jon Thorne
Reply

Thanks Dmitrij,

Perhaps I was not so clear. I am talking about the batch integration and importing a list of products from NAV. Not all the products in the ERP will be in the webstore. Is there any way of adding a filter to this xml to only retrieve a subset of the products from NAV? Is it possible to set type="filter" and then add a filter for a group of products?

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

I know that I could probably filter out products that I receive that are not needed. But I was hoping not to transfer lots of data that is not necessary.

Regards, Jon.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Jon,

You can try adding an XSLT file where you can add some filtering or you can use the option on the Table mapping where you can add some conditions:

 

 

Adrian

 
Jon Thorne
Jon Thorne
Reply

Hi Adrian,

Yes I saw that option, but I assume that will just filter out the results after all the data has already been received from the ERP. I was hoping to only transfer the data that was needed. At least this would get the result I am after.

I assume then that the only way to stop the extra product data from being sent would require an update to the code unit to help with the filtering. I was hoping that this may have been part of the standard setup.

Regards, Jon.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Jon,
if you want to filter the products on the EPR side then only in the BC extension you can try to implement that.
In the standard BC "Dynamicweb Plugin unit" app there is a notification event in the:
codeunit 6211202 DynamicwebProductsPublisher
method:
OnBeforeFindItems
It has a parameter called "item" that is referencing all items in BC, so you can add your custom filter to it:
item.SETFILTER("No.", '>%1', 1000);
So your method can look like that:

[EventSubscriber(ObjectType::Codeunit, Codeunit::DynamicwebProductsPublisher, 'OnBeforeFindItems', '', true, true)]
    procedure OnBeforeFindItems(var item: Record Item; var requestDoc: XmlDocument);
    begin
        item.SETFILTER("No.", '>%1', Format(1000));
    end;

Then you can install your custom app on top of our app inside the BC.
BR, Dmitrij
 
Jon Thorne
Jon Thorne
Reply

Hi Dmitrij,

Thanks that is helpful. I have another project with BC coming up soon that can use this method. For NAV I think we will get the code unit customised to handle this.

It would be helpful to understand if anyone can comment on how others handle this situation, as I assume it is very common. In a scenario where products are all managed from the ERP and not all the products are displayed on the webstore. How is that managed from the ERP? Or does it always have to be managed from DW after the products are added?

Regards, Jon.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Jon,
We usually ask the ERP partner to take care of the filtering of what we are consuming.

Sometimes that's possible, sometimes it is not and we have to customize the code.

Thank you,
Adrian

 

You must be logged in to post in the forum