Get all products assigned to campaign

How can I get all products assigned to a Campaign? I am aware that there are some different ways of assigning products to a campaign (list, assortment, category, individual product), so I’m guessing I have to do some lookups to the different services to get all the products, but I am unure which part of the Campaign object to use for this.

Litium version: 7.7.9

Hi,

What is your purpose? Getting products assigned to a campaign can cause performance issues depending on the purpose.

The customer wants all products which are active in a campaign to be put into a product list. We are aware of the risk of performance issues and have recommended that this be run as a scheduled task once every 24hrs at night when traffic is low.

Would it be a risk even with these requirements?

Hi again,

It depends on how many active campaigns you have. You can do something like below and can maybe use the search to get the products. You have to have a similar if for each action type.

            if (actionData is ReducePriceByPercentageAction.Data)
            {
                var data = (ReducePriceByPercentageAction.Data) actionData;
                 if (data.SelectedIdType == ReducePriceByPercentageAction.Data.SelectionCriteria.Articles)
                 {
                        // data.SelectedIDs contains variant ids 
                       //  Get products via variants
                 }
                 if (data.SelectedIdType == ReducePriceByPercentageAction.Data.SelectionCriteria.ProductGroups)
                 {
                        // data.SelectedIDs contains category ids
                        // Get products via poduct category
                 }
                 if (data.SelectedIdType == ReducePriceByPercentageAction.Data.SelectionCriteria.ProductSets)
                  {
                        // data.SelectedIDs contains product list ids 
                       // Get products via product list
                  }
                  if (data.SelectedIdType == ReducePriceByPercentageAction.Data.SelectionCriteria.Assortments)
                  {
                        // data.SelectedIDs contains assortment ids 
                       // Get products via assortment
                  }
             }

Thanks, Utku. I’ll try this and see if it is realistic to run every night.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.