Developer forum

Forum » Integration » Deactivating variants without deactivating master products during import

Deactivating variants without deactivating master products during import

Anders Ebdrup
Reply

Dear DynamicWeb,

We have a setup where products are imported, and master / variant relationships are created and maintained in the DynamicWeb administration.

Our requirement is to be able to deactivate missing variants while keeping the master product active when importing product data from ERP.

However, we are unsure what the recommended or supported approach is in DynamicWeb. Specifically, we would like to know:

  • Is it possible to deactivate only variants without affecting the master product?
  • Are there any best practices for handling variant activation/deactivation during imports?
  • Is this supported natively, or does it require a custom import or logic?

Any guidance or examples would be very helpful, as this is a common scenario when variants become unavailable but the main product should remain active.

 

Best regards, Anders


Replies

 
Michael Knudsen
Reply

Hello Anders,

- even I'm not on DynamicWeb's payroll, would I flip my 5 cents in here :-)  Most of it are supported natively, but in the case where the primary variant are deactivated, then would it require an manual process to select the new primary variant.

But let's see if DynamicWeb have a better solution.

Br. Michael Knudsen

 
Andrew Rushworth
Reply

We have implemented scripts that will auto select the next available variant (based on certain criteria) for a product if the current default variant is:
(a) not set
(b) is out of stock
(c) is deactive
We then run these periodically run this.

We then also have scripts to allert of products where the current default is out of stock and there are not available variants.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

If you set active to be editable across variants, you can set the variant to inactive.

I do not understand your reamining questions. What is a missing variant?

 
Anders Ebdrup
Reply

Dear Nicolai,

 

It is when importing products from the ERP-systems, where we normally activate this setting: "Deactivate missing products" on the destination setting of an import job. But when we are working with variants in the PIM, then we cannot use the setting as it will deactivate the master products as they only exists in DW and not the ERP.

So what is best practise to have only missing "variants" (which are actually products from the ERP, but variants in DW) deactivated then importing products?

 

Best regards, Anders

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Would staging tables as described here: https://doc.dynamicweb.com/community/devblog/blog/alternatives-to-applying-code-in-you-integration-flow?PID=8967 help?

1. You insert products into a temp table

2. You use a view against that table to insert / update new and existing products

3. You then use the temp table and another view to detect missing records and disable those? The view could return variants only so masters won't be affected.

Imar

 
Anders Ebdrup
Reply

Dear Imar,

Yes, that approach would definitely solve the issue. However, I was hoping there might be a more standard or built-in way to handle this scenario, as it seems quite common to work with master/variant structures in PIM while regularly importing products from an ERP.

I was therefore wondering if I had overlooked something obvious in the standard setup or configuration.

In any case, thank you very much for the assistance.

Best regards,
Anders

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

The “Deactivate missing products” is available in the Dynamicweb and Ecom destination providers but there is no feature to just deactivate only master or variant products. That would have to be (yet another) new setting.

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Guys,
Maybe a combination of a standard import job and a subtask running a SQL statement after the import to activate all Master products with active variants?
It may not be a standard checkbox in the import job, but it can still use a standard DW approach without staging tables.

Adrian

 

 

 

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Yes, that could work as well. I just found this in a very old project where we run this in a JobFinished subscriber for the same reason. It should update masters correctly based on the presence of more than one unique product ID (the master and at least one variant) with a variant being active and the master not being active:

UPDATE EcomProducts
SET ProductActive = 1
WHERE
    ProductId in
    (
      Select ProductId from EcomProducts
      Group by ProductId
      Having count(*) > 1
    )
AND
    ProductId in
    (
      Select ProductId from EcomProducts
      WHERE ProductVariantId <> ''
      AND ProductActive = 1
    )
AND
    ProductVariantId = '' and productActive = 0

 

Imar

 

 

You must be logged in to post in the forum