Try our conversational search powered by Generative AI!

How to set promotion for category with linked products?

Vote:
 

I have a category in catalog called "On Sale" with Code - "On-Sale_2". Now I add linked product (it includes all variations too) to this category.

Then I set promotion like this with these conditions:

TargetLineItem.CatalogNode - Equals (Text) - On Sale

and rewards:

get % off item reward 70%

But discount is not applied for the product. When I remove conditions then discount is applied to all products.

I also tried these conditions:

TargetLineItem.CatalogEntryId - Equals (Text) - On-Sale_2
What is the proper way to apply discount to category with linked products?
#119995
Apr 08, 2015 15:52
Vote:
 

Hi,

The CatalogNode value is not set automatically when you create the line item. So you might want to set it when you add an entry to card. Check if the entry is linked to the catalog node then set it.

The CatalogEntryId is the code of the entry, will be set automatically, and should not work in your case.

Regards.

/Q

#119999
Apr 08, 2015 16:49
Vote:
 

I need price to be shown also in the product list, not only when add to cart. To get the price I am using:

var price = StoreHelper.GetDiscountPrice(entry);

I decompiled this method and see that it goes through all CatalogNodes for Entry and concatenates codes and names and appies to promotion:

if (entry.Nodes != null && entry.Nodes.CatalogNode != null && entry.Nodes.CatalogNode.Length > 0)
      {
        foreach (CatalogNode catalogNode in entry.Nodes.CatalogNode)
        {
          string name = CatalogContext.Current.GetCatalogDto(catalogNode.CatalogId).Catalog[0].Name;
          if ((string.IsNullOrEmpty(catalogName) || name.Equals(catalogName)) && (string.IsNullOrEmpty(catalogNodeCode) || catalogNode.ID.Equals(catalogNodeCode, StringComparison.OrdinalIgnoreCase)))
          {
            catalogName1 = !string.IsNullOrEmpty(catalogName1) ? catalogName1 + ";" + name : name;
            catalogNodeCode1 = !string.IsNullOrEmpty(catalogNodeCode1) ? catalogNodeCode1 + ";" + catalogNode.ID : catalogNode.ID;
          }
        }
      }

So I assumed that my Promotion settings was almost correct except that I had to change comparision Equals (Text) to Contains:

TargetLineItem.CatalogNode - Contains - On-Sale_2

But discount still is not applied.

P.S. I am creating Promotion as Catalog Entry: Build Your Own Discount

#120038
Edited, Apr 09, 2015 9:39
Vote:
 

Started to look more deeply and found this in MarketingContext method EvaluatePromotions:

  if (context.TargetEntriesSet.Entries.Count > 0)
  {
	bool flag3 = true;
	foreach (PromotionEntry promotionEntry in (IEnumerable<PromotionEntry>) context.TargetEntriesSet.Entries)
	{
	  string catalogEntryCode = promotionEntry.CatalogEntryCode;
	  string catalogNodeCode = promotionEntry.CatalogNodeCode;
	  string catalogName = promotionEntry.CatalogName;
	  if (!string.IsNullOrEmpty(catalogEntryCode) || !string.IsNullOrEmpty(catalogNodeCode) || !string.IsNullOrEmpty(catalogName))
	  {
		PromotionDto.PromotionConditionRow[] promotionConditionRows = promotionItem.DataRow.GetPromotionConditionRows();
		if (promotionConditionRows != null && promotionConditionRows.Length > 0)
		{
		  foreach (PromotionDto.PromotionConditionRow promotionConditionRow in promotionConditionRows)
		  {
			if (!string.IsNullOrEmpty(catalogEntryCode) && !promotionConditionRow.IsCatalogEntryIdNull() && !promotionConditionRow.CatalogEntryId.Equals(catalogEntryCode))
			{
			  flag3 = false;
			  break;
			}
			if (!string.IsNullOrEmpty(catalogNodeCode) && !promotionConditionRow.IsCatalogNodeIdNull() && !promotionConditionRow.CatalogNodeId.Equals(catalogNodeCode))
			{
			  flag3 = false;
			  break;
			}
			if (!string.IsNullOrEmpty(catalogName) && !promotionConditionRow.IsCatalogNameNull() && !promotionConditionRow.CatalogName.Equals(catalogName))
			{
			  flag3 = false;
			  break;
			}
		  }
		  int num = flag3 ? 1 : 0;
		}
	  }
	}
	if (!flag3)
	  continue;
  }

Maybe I am wrong, but it looks like it totally ignores condition type (equals or contains) when evaluates promotion for CatalogName, CatalogNodeId and CatalogEntryId and expects it to excatly equal to provided code. And as I saw previously from StoreHelper it concatenates all categories (names and codes) separated by semicolon. So it is not likely that such condition ever be true:

promotionConditionRow.CatalogNodeId.Equals(catalogNodeCode)

For example, if configured CatalogNodeId = 'Accessories' and catalogNodeCode = 'Accessories;On-Sale':

'Accessories'.Equals('Accessories;On-Sale')

It is always false.
#120044
Apr 09, 2015 10:22
Vote:
 

Try using 

TargetLineItem.CatalogNode - Contains (Text) - On Sale

instead of 

TargetLineItem.CatalogNode - Equals (Text) - On Sale

#122470
Jun 03, 2015 10:52
Vote:
 

The bug related to this was fixed in in 8.12.0, you'll need to update to that version to have it worked for you.

Regards.

/Q

#122472
Jun 03, 2015 10:57
Vote:
 

Thanks, I will update my solution.

#122493
Jun 03, 2015 13:01
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.