Promotions Entity Views and Actions APIの操作 (C#)

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

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

外部システムは、Sitecore XCプロモーション関連の操作を統合し、Sitecore XCプロモーション エンティティ ビューとアクションAPIを使用してプロモーション関連データを他のシステムと交換できます。

この に示すように、Commerce Engineの操作とコマンドをコンテナ呼び出しに含める必要があります (C# を使用)。

Sitecore Experience Commerce (XC) システムで操作を実行するには、呼び出し元のシステムはまずSitecore Identity Serverの 有効なベアラー認証トークンを取得する 必要があります。

Promotions View APIとActions APIは、プロモーション ブックのAddGetEditManage Associated Catalogsに対するアクションをサポートしています。

メモ

Views and Actions APIは、ビジネス・ユーザー・インターフェースを提供するように設計された オーサリングAPIであり、統合シナリオ用には最適化されていません。

コマース統合にViews and Actions APIを使用する場合は、次の点を考慮する必要があります。

  • Views and Actions APIは、一度に1つのCommerceエンティティのみを処理でき、バッチ処理をサポートしていません。

  • Views and Actions APIは、Commerce WebサービスAPIよりも多くのオーバーヘッドを伴います。Views and Action APIの呼び出しは、通常、アクションのビューを取得し、更新された値でビューのプロパティを変更してから、アクションを実行する必要がある3段階のプロセスです。

プロモーション ブックの追加 (C#)

APIリクエストを使用して、新しいプロモーションブックをプログラムで作成できます。プロモーション ブックが存在すると、その名前を変更することはできません。プロモーションブックは削除できません。

C# を使用してプロモーションブックを追加するには:

  1. エンティティ ビューを取得します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView(string.Empty, "Details", "AddPromotionBook", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. ビューのプロパティを変更するには、NameDisplayName 、およびDescriptionを指定します。たとえば、次の例です。

    var nameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Name"));
    nameProperty.Value = "MyPromotionBook";
    var displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName"));
    displayNameProperty.Value = "Book Display Name";
    var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description"));
    descriptionProperty.Value = "Book Description";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

プロモーション ブックからビューを取得する (C#)

Views APIを使用して、プロモーション ブックのさまざまなビューを取得できます。

手記

Views APIはComposite EntityViewsを使用します。マスタービューをリクエストできますが、子ビューもリクエストできます。

プロモーションのブックマスタービューの取得

プロモーションのブックマスタービューを取得するには:

DataServiceActionQuerySingle<EntityView> query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Master", string.Empty, string.Empty);
EntityView view = Proxy.GetValue(query);

プロモーションブックの詳細ビューを取得する

プロモーションブックの詳細ビューを取得するには:

query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Details", string.Empty, string.Empty);
view = Proxy.GetValue(query);

プロモーションブックの関連カタログビューの取得

プロモーションブックに関連付けられたカタログビューを取得するには:

query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "PromotionBookCatalogs", string.Empty, string.Empty);
view = Proxy.GetValue(query);

プロモーションブックのプロモーションビューを取得する

プロモーションブックのビューを取得するには:

query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Promotions", string.Empty, string.Empty);
view = Proxy.GetValue(query);

プロモーション ブックの編集 (C#)

既存のプロモーションブックのDisplayNameプロパティとDescriptionプロパティの値を変更できます。内部名 ( Nameプロパティの値) は変更できません。要求で値が指定されていない場合、既存の値は変更されません。

プロモーションブックの詳細を編集するには:

  1. エンティティ ビューを取得します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Details", "EditPromotionBook", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. たとえば、次の例に示すように、DisplayNameまたはDescriptionまたはその両方を指定して、ビューのプロパティを変更します。

    var displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName"));
    displayNameProperty.Value = "Edited Book Display Name";
    var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description"));
    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));descriptionProperty.Value = "Edited Book Description";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

カタログをプロモーション ブックに関連付ける (C#)

カタログをプロモーションに関連付けて、ブックで定義されたプロモーションをカタログ品目に適用できるようにします。プロモーション ブックは複数のカタログに関連付けることができますが、カタログは1つのプロモーション ブックにのみ関連付けることができます。

カタログをプロモーションブックに関連付けるには:

  1. エンティティ ビューを取得します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", string.Empty, "DisassociateCatalog", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. たとえば、ビューのプロパティを変更して、関連付けるカタログを指定します。たとえば、次のようにします。

    view.ItemId = "MyCatalog";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

プロモーションを追加する (C#)

プロモーション ブック内でプロモーションを作成します。プロモーション ブック内では、プロモーションの名前は一意である必要があります。プロモーションの名前は変更できません。

プロモーションを追加するには:

  1. エンティティ ビューを取得します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Details", "AddPromotion", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. ビューのプロパティを変更して、プロモーションの詳細を指定します。たとえば、次のようにします。

    var nameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Name"));
    nameProperty.Value = "MyPromotion";
    var displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName"));
    displayNameProperty.Value = "Promotion Display Name";
    var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description"));
    descriptionProperty.Value = "Promotion Description";
    var displayTextProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayText"));
    displayTextProperty.Value = "Promotion Text";
    var displayCartTextProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayCartText"));
    displayCartTextProperty.Value = "Promotion Cart Text";
    var validFromProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ValidFrom"));
    validFromProperty.Value = DateTimeOffset.UtcNow.ToString(CultureInfo.InvariantCulture);
    var validToProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ValidTo"));
    validToProperty.Value = DateTimeOffset.UtcNow.AddDays(30).ToString(CultureInfo.InvariantCulture);
    var isExclusiveProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("IsExclusive"));
    isExclusiveProperty.Value = "true";
  3. アクションを実行する

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

    このリクエストは、プロモーションのわかりやすいIDをPromotionAddedモデルの一部として返します。たとえば、次のようにします。

    PromotionAdded promotionAddedModel = command.Models.OfType<PromotionAdded>().FirstOrDefault();
    string promotionFriendlyId = promotionAddedModel?.PromotionFriendlyId;

プロモーションのビューを取得する (C#)

Views APIを使用して 、プロモーションのさまざまなビュー を取得できます。

プロモーションのマスタービューを取得するには:

DataServiceActionQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Master", string.Empty, string.Empty);
EntityView view = Proxy.GetValue(query);

プロモーションの詳細ビューを取得するには:

query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Details", string.Empty, string.Empty);
view = Proxy.GetValue(query);

プロモーションの資格ビューを取得するには:

query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Qualifications", string.Empty, string.Empty);
view = Proxy.GetValue(query);

プロモーションの特典ビューを取得するには:

query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Items", string.Empty, string.Empty);
view = Proxy.GetValue(query);

プロモーションのアイテム ビューを取得するには:

query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Items", string.Empty, string.Empty);
view = Proxy.GetValue(query);

プロモーションの公開クーポンのビューを取得するには:

query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "PublicCoupons", string.Empty, string.Empty);
view = Proxy.GetValue(query);
view = Proxy.GetValue(query);

プロモーションのプライベートクーポンのビューを取得するには:

query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "PrivateCoupons", string.Empty, string.Empty);
view = Proxy.GetValue(query);

プロモーションの編集 (C#)

既存のプロモーションのプロパティの値を変更することができます。

手記

プロモーションにaを変更できるのは、プロモーションがDraft状態の場合のみです。

プロモーションを編集するには:

  1. エンティティ ビューを取得します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Details", "EditPriceCard", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. 必要に応じて、次のようにビューのプロパティを変更します。

    手記

    DisplayNameDescriptionに値が指定されていない場合、現在の値は変更されません。残りのプロパティは必須です。(IsRequired"true"に設定されている場合は、プロパティが必要です。

    var displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName"));
    displayNameProperty.Value = "Edited Promotion Display Name";
    var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description"));
    descriptionProperty.Value = "Edited Promotion Description";
    var displayTextProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayText"));
    displayTextProperty.Value = "Edited Promotion Text";
    var displayCartTextProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayCartText"));
    displayCartTextProperty.Value = "Edited Promotion Cart Text";
    var validFromProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ValidFrom"));
    validFromProperty.Value = DateTimeOffset.UtcNow.AddDays(3).ToString(CultureInfo.InvariantCulture);
    var validToProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ValidTo"));
    validToProperty.Value = DateTimeOffset.UtcNow.AddDays(33).ToString(CultureInfo.InvariantCulture);
    var isExclusiveProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("IsExclusive"));
    isExclusiveProperty.Value = "false";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

条件を追加する (C#)

資格とは、プロモーションに設定する条件であり、プロモーション特典を買い物客の注文に適用するために満たす必要がある条件です。 Sitecore XCには 、プロモーションに適用できる複数の資格が用意されています。

プロモーションに資格を追加するには:

  1. たとえば、エンティティ ビューを取得して、プロモーションにCart Has [count] items?資格を追加します。

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "QualificationDetails", "SelectQualification", string.Empty));
    var conditionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Condition"));
    var availableConditionsPolicy = conditionProperty.Policies.OfType<AvailableSelectionsPolicy>().FirstOrDefault();
    conditionProperties.Value = availableConditionsPolicy?.List.FirstOrDefault(o => o.Name.Equals("CartHasItemsCountCondition")).Name;
    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));
  2. 認定値を設定します。次の例では、Cart Has [count] items?のアイテム数が3に設定されています。

    view = command.Models.OfType<EntityView>().FirstOrDefault(v => v.Name.Equals(view.Name));
    var countProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Count"));
    countProperty.Value = "3";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

    認定IDは、次のようにQualificationAddedモデルで返されます。

    var qualificationId = addAction.Models.OfType<QualificationAdded>().FirstOrDefault()?.QualificationId;

条件の編集 (C#)

既存の条件は、Views/Actions APIを使用して変更できます。

条件を編集するには (たとえば、Cart Has [count] Items?条件を編集するには、countプロパティを5に設定します。

  1. エンティティ ビューを取得します。

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "QualificationDetails", "EditQualification", qualificationId));
  2. 必要に応じて、Cart Has [count] Items?条件の項目数を5に変更するには、必要に応じて条件のプロパティ値を編集します。

    var countProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Count"));
    countProperty.Value = "5";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

特典を追加する (C#)

特典とは、プロモーションに適用される可能性のある割引です。特典は、プロモーションの資格条件が満たされた場合に、お客様の注文に適用されます。 Sitecore XCでは、1つのプロモーションに適用できる特典が事前に定義されています。1つのプロモーションに複数の特典を追加できます。

プロモーションに特典を追加するには:

  1. エンティティ ビューを取得します (たとえば、プロモーションにGet Cart Subtotal [specific] Amount Off特典を適用する場合など)。

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "BenefitDetails", "SelectBenefit", string.Empty));
    var actionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Action"));
    var availableActionsPolicy = actionProperty.Policies.OfType<AvailableSelectionsPolicy>().FirstOrDefault();
    actionProperty.Value = availableActionsPolicy?.List.FirstOrDefault(o => o.Name.Equals("CartSubtotalAmountOffAction")).Name;
    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));
  2. 給付金値プロパティを設定します。たとえば、次の例では、AmountOff値を50に設定します。

    view = command.Models.OfType<EntityView>().FirstOrDefault(v => v.Name.Equals(view.Name));
    var amountProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("AmountOff"));
    amountProperty.Value = "50";
    command = Proxy.DoCommand(container.DoAction(view));"CartSubtotalAmountOffAction
  3. アクションを実行します。

    command = Proxy.DoCommand(container.DoAction(view));

    特典IDは、次のようにBenefitAdded モデルを使用して返されます。

    var benefitId = addAction.Models.OfType<BenefitAdded>().FirstOrDefault()?.BenefitId;

特典の編集 (C#)

既存の特典に変更を加えるには、そのプロパティ値を変更します。

特典を編集するには (たとえば、Get Cart Subtotal [specific] Amount Off特典の割引額の値を変更するには):

  1. エンティティ ビューを取得します。

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "BenefitDetails", "EditBenefit", benefitId));
  2. "AmountOff" プロパティの値を次のように変更します (例: 20

    var amountProperty = view.Properties.FirstOrDefault(p =&gt; p.Name.Equals("AmountOff"));
    amountProperty.Value = "20";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

特典の削除 (C#)

プロモーションの特典を削除できます。

特典を削除するには:

  1. エンティティ ビューを取得し、プロモーションのフレンドリIDと削除する特典IDをクエリに含めます (例:

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, string.Empty, "DeleteBenefit", benefitId));
  2. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

プロモーションに項目を追加する (C#)

目的ステートメントを確認する必要があります - ステップ2のコード サンプルと一致しているかどうかはわかりませんアイテム (Sellableアイテムやアイテムのバリアントなど) をプロモーションに追加して、プロモーションが個々のアイテムに適用されるようにします (カタログ レベルでプロモーションを適用するのではなく)。

手記

プロモーションを変更できるのは、プロモーションがDraft状態の場合のみです。 approved 状態のプロモーションは変更できません。

プロモーションにアイテムを追加するには:

  1. エンティティ ビューを取得します。

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "ItemDetails", "AddItem", string.Empty));
  2. ビューのプロパティを変更します。たとえば、プロモーションにnot excludedプロパティを追加します。

    var catalogProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Catalog"));
    var availableCatalogsPolicy = catalogProperty.Policies.OfType<AvailableSelectionsPolicy>().FirstOrDefault();
    catalogProperty.Value = availableCatalogsPolicy?.List.FirstOrDefault(o => o.Name.Equals("MyCatalog"))?.Name;
    var itemIDProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ItemId"));
    itemIDProperty.Value = "MyProduct|MyCatalog|MyVariant";
    var excludedProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Excluded"));
    excludedProperty.Value = "false";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

    アイテムIDは、次のようにPromotionItemAdded モデルを使用して返されます。

    string itemId = command.Models.OfType<PromotionItemAdded>().FirstOrDefault()?.PromotionItemId;

プロモーションからの項目の削除 (C#)

プロモーションからアイテムを削除するには、Views and Actions APIを使用します。

プロモーションからアイテムを削除するには:

  1. エンティティ ビューを取得し、プロモーションのフレンドリIDと削除するアイテムIDをクエリに含めます。

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, string.Empty, "RemoveItem", itemId));
  2. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

プロモーションへの公開クーポンの追加 (C#)

公開クーポンは、複数回使用できるテキストの文字列です。

プロモーションに公開クーポンを追加するには:

  1. エンティティ ビューを取得します。

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "PublicCoupons", "AddPublicCoupon", string.Empty));
  2. ビューのプロパティを変更して、codeProperty.Valueを指定します。たとえば、次の例です。

    var codeProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Code"));
    codeProperty.Value = "MyPublicCoupon_ABC123";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

プロモーションへのプライベート クーポンの追加 (C#)

プライベートクーポンは、1人の顧客に割り当てられた割引コードです。作成するプライベートクーポンの数を指定できます

プロモーションにプライベートクーポンを追加するには:

  1. エンティティ ビューを取得します。たとえば、次のようにします。

    string promotionId = $"Entity-Promotion-{promotionFriendlyId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "CouponDetails", "AddPrivateCoupon", string.Empty));
  2. ビューのプロパティを変更して、クーポンの割り当ての詳細を指定します。次に示すのは、20個の可能な割り当てを作成するクエリです。

    var prefixProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Prefix"));
    prefixProperty.Value = "before_";
    var suffixProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Suffix"));
    suffixProperty.Value = "_after";
    var totalProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Total"));
    totalProperty.Value = "20";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

    クーポンに適したIDは、PrivateCouponGroupAddedモデルを使用して返されます (例:

    string privateCouponId = command.Models.OfType<PrivateCouponGroupAdded>().FirstOrDefault()?.GroupFriendlyId;

プライベート クーポンの割り当て (C#)

Promotions Views and Actions APIを使用して、生成された非公開クーポンを特定のプロモーションキャンペーンに割り当てることができます。

プライベートクーポンを割り当てるには:

  1. アクションのエンティティ ビューを取得します。

    string groupId = $"Entity-PrivateCouponGroup--{privateCouponId}";
    EntityView view = Proxy.GetValue(container.GetEntityView(groupId, "AllocationDetails", "NewAllocation", string.Empty));
  2. たとえば、ビューのプロパティを変更して、10個のクーポンを割り当てます。

    var countProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Count"));
    countProperty.Value = "10";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

    割り当てられたクーポン コードの一覧は、PrivateCouponListモデルを使用して返されます。

プロモーションの複製 (C#)

Views and Actions APIを使用して既存のプロモーションを複製し、同じプロモーション ブック内に新しいプロモーションを作成できます。新しいプロモーションはDraft ステータスになり、編集できます。

プロモーションを複製するには:

  1. アクションのエンティティ ビューを取得します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Details", "DuplicatePromotion", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. 次のように、ビューのプロパティを変更します。

    var nameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("PromotionDuplicateName"));
    nameProperty.Value = "MyDuplicatePromotion";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

プロモーションステータスの変更

プロモーションは、プロモーション承認プロセスの対象となります。承認フロー中、プロモーションステータスは次のように移行できます。

承認のためにプロモーションを送信する (C#)

プロモーションの下書きを提出して承認を受けることができます。

プロモーションの承認をリクエストするには:

  1. アクションのビューを取得します。

    // requesting approval
    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "SetPromotionApprovalStatus", "RequestPromotionApproval", snapshotId);
    EntityView view = Proxy.GetValue(query);
  2. ビューのプロパティを変更して承認を要求します。

    var commentProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Comment"));
    commentProperty.Value = "Requesting approval";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

    プロモーションのステータスがDraftからReadyForApprovalに変わります。

昇格を拒否する (C#)

プロモーションは、ステータスがReadyForApprovalの場合に拒否できます。

プロモーションを却下してドラフトステータスに戻すには:

  1. アクションのビューを取得します。

    // rejecting
    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "SetPromotionApprovalStatus", "RejectPromotion", snapshotId);
    EntityView view = Proxy.GetValue(query);
  2. ビューのプロパティを変更して、承認リクエストを拒否します。

    var commentProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Comment"));
    commentProperty.Value = "Rejecting approval";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

    プロモーションはDraft ステータスに戻ります。

プロモーションの承認 (C#)

プロモーションを承認できるのは、そのステータスがReadyForApprovalの場合です。

プロモーションを承認するには:

  1. アクションのビューを取得します。

    // approving
    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "SetPromotionApprovalStatus", "ApprovePromotion", snapshotId);
    EntityView view = Proxy.GetValue(query);
  2. ビューのプロパティを変更して、プロモーションを承認します。

    var commentProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Comment"));
    commentProperty.Value = "Approving";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

    プロモーションのステータスがApprovedに変わります。

承認済みのプロモーションを無効にする

承認済みのプロモーションを無効にすることができます。プロモーションを無効にすると、そのプロモーションは承認されたままになりますが、アクティブではなくなります。無効にしたプロモーションを再度アクティブ化することはできません。

承認済みのプロモーションを無効にするには

  1. アクションのビューを取得します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "SetPromotionApprovalStatus", "RetractPromotion", snapshotId);
    EntityView view = Proxy.GetValue(query);
  2. ビューのプロパティを変更して、アクティブなプロモーションを無効にします。

    var commentProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Comment"));
    commentProperty.Value = "Retracting the promotion";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

プロモーションの削除 (C#)

プロモーションは、Draftステータスのときに削除できます。

プロモーションを削除するには:

  1. アクションのエンティティ ビューを取得します。たとえば、次のようにします。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", string.Empty, "DeletePromotion", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. ビューのプロパティを変更して、promotionFriendlyIdを指定します。たとえば、次の例です。

    view.ItemId = $"Entity-Promotion-{promotionFriendlyId}";
  3. アクションを実行します。

    CommerceCommand command = Proxy.DoCommand(container.DoAction(view));
この記事を改善するための提案がある場合は、 お知らせください!