Try our conversational search powered by Generative AI!

Accessing lineitems properties in LineItemValidator.IsValidCatalog

Vote:
 

Hi,

We used the ValidateLineItemsActivity to change a certain validation:

var isPromoItem = lineItem["IsPromoItem"] != null;

//check if the entry is not available
if ((!isPromoItem && !entryRow.IsActive) || requestDate < minAvailableDate || requestDate > entryRow.EndDate)
{
AddWarningSafe(Warnings, "LineItemRemoved-" + lineItem.LineItemId.ToString(),
String.Format("Item \"{0}\" has been removed from the cart because it is not available.",
lineItem.DisplayName));
lineItemsToRemoved.Add(lineItem);
continue;
}

If I'm not mistaken, I should now use the IsValidCatalog in my custom DefaultLineValidator to add my validation:

protected override bool IsValidCatalog(EntryContentBase entry, DateTime requestDate)
{
CatalogDto.CatalogRow catalogRow = this._catalogSystem.GetCatalogDto(entry.CatalogId).Catalog.FirstOrDefault();
if (catalogRow != null && catalogRow.IsActive && requestDate >= catalogRow.StartDate)
return requestDate <= catalogrow.enddate;>
return false;
}

My problem is that our custom property was on the lineitem and now I only have a EntryContentBase. Is there a way to access ou property from this function?

If not, how should I fix this?

#195087
Jul 12, 2018 21:54
Vote:
 

You should have to override Validate(ILineItem lineItem, MarketId marketId, Action<ILineItem, ValidationIssue> onValidationError) instead :) 

#195098
Jul 13, 2018 10:14
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.