I am working with Commerce 12.3.1, the DisplayName property of the line item is not being saved.
The below code snippet is present in the custom implementation of UpdatePlacedPrice method of DefaultPlacedPriceProcessor class.
//If display name is not present use the parent name
string DisplayName = entry.GetPropertyValue("DisplayName");
DisplayName = string.IsNullOrEmpty(DisplayName) ? entry.Name : DisplayName;
if (!string.Equals(lineItem.DisplayName, DisplayName))
lineItem.DisplayName = DisplayName;
But when it saves to cart, the display name is blank. Below is the scenario:
Create a line item with DisplayName = "Test Display Name", I then save the cart using the code snippet below:
var orderService = ServiceLocator.Current.GetInstance();
But once I check the InMemoryLineItem object's DisplayName property it is blank.
Can you share a bit more of your code, for example where you call these methods and/or where you create the LineItem?
With the limited information, here are some things to check:
First, just to cover our bases, does entry.Name contain a value? With the code example you gave DisplayName will remain empty if both entry.GetPropertyValue("DisplayName") and entry.Name are empty.
Second, in regards to separation of concerns, why are you setting DisplayName in a method related to updating prices? I'd look into putting the code that does this in another place. For example closer to where you create the LineItem.