9.2

Business Toolsで追加情報を表示するためにCommerceビューを拡張

日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

Commerceビューを拡張して、Sitecore XC Business Toolsユーザーインターフェースで追加情報を表示できます。以下は、Entity Viewを拡張して、注文詳細ページで獲得したポイントの概要を表示する方法の例です。ビューを拡張するために、新しいEntityViewブロックを追加しています。

商業ビューを拡張して追加情報を表示するには:

  1. サンプルブロックをコピー&ペーストし、名前をGetOrderSummaryViewBlock。

  2. GetEntityViewブロックはEntityViewをパラメータとして取り、EntityViewを返します。この拡張は命令を認識しなければならず、例えばOrdersプラグインへの参照を追加する必要があります。

    Sitecore.Commerce.Plugin.Orders": "1.0.2301

  3. 新しいブロックを追加:

    if (request.ViewName != context.GetPolicy().Summary && request.ViewName != context.GetPolicy().Master) { // Do nothing if this request is for a different view return Task.FromResult(entityView); } if (request.Entity == null) { // Do nothing if there is no entity loaded return Task.FromResult(entityView); } // Only do something if the Entity is an order if (!(request.Entity is Order)) { return Task.FromResult(entityView); } var order = request.Entity as Order; EntityView entityViewToProcess; if (request.ViewName == context.GetPolicy().Master) { entityViewToProcess = entityView.ChildViews.FirstOrDefault(p=>p.Name == "Summary") as EntityView; } else { entityViewToProcess = entityView; } int pointsEarned = 0; foreach(var line in order.Lines.Where(p=>p.HasComponent())) { pointsEarned = pointsEarned + line.GetComponent().Points; } entityViewToProcess.Properties.Add(new ViewProperty { Name = "Points Earned", IsReadOnly = true, RawValue = pointsEarned }); return Task.FromResult(entityView);

この記事を改善するための提案がある場合は、 お知らせください!