1. カタログ統合

Sellable商品のエンティティ アクションとビュー APIの操作

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

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

Sitecore Experience Commerceは、Catalog Entity Views and Actions APIを使用して、製品関連データを他のビジネス システムと交換できます。

メモ

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#)

次の例は、C# を使用してSellable商品を取得する方法を示しています。

DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-SellableItem-{SellableItemId}", "Details", string.Empty, string.Empty); EntityView view = Proxy.GetValue(query);

Sellable商品の作成 (C#)

次の例は、C# を使用してSellable商品を作成する方法を示しています。

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

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Catalog-{Catalog}", "Details", "AddSellableItem", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. Sellable商品のプロパティを指定します。

    var ProductId = view.Properties.FirstOrDefault(p => p.Name.Equals("ProductId"));
    var Name= view.Properties.FirstOrDefault(p => p.Name.Equals("Name"));
    var DisplayName = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName"));
    var Description = view.Properties.FirstOrDefault(p => p.Name.Equals("Description"));
    var Brand = view.Properties.FirstOrDefault(p => p.Name.Equals("Brand"));
    var Manufacturer = view.Properties.FirstOrDefault(p => p.Name.Equals("Manufacturer"));
    var TypeOfGood = view.Properties.FirstOrDefault(p => p.Name.Equals("TypeOfGood"));
    	
    ProductId.Value = "SomeProductId".ProposeValidId(); //ProposeValidId will try to convert your string to a safe string to use.
    Name.Value = "AHotProduct";
    DisplayName.Value = "A Hot New Product";
    Description.Value = "The hottest product on the market today";
    Brand.Value = "Hot Stuff Brands";
    Manufacturer.Value = "Hot Stuff Manufacturers";
    TypeOfGood.Value = "Physical Item";
  3. アクションを実行します。

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

Sellable商品の削除 (C#)

次の例は、C# を使用してSellable商品を削除する方法を示しています。

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

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Category-{Category}",string.Empty, "DeleteSellableItem", "Entity-SellableItem-{SellableItemId}");
    EntityView view = Proxy.GetValue(query);
  2. Sellable商品を削除します。

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

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

Sellable商品を更新する (C#)

次の例は、エンティティ ビューとアクションAPIを使用して、C# でSellable商品の詳細を更新する方法を示しています。

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

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-SellableItem-{SellableItemId}", "Details", "EditSellableItemDetails", string.Empty);
    EntityView view = Proxy.GetValue(query);
    	
  2. ビューのプロパティを変更して、更新する詳細を含めます。

    var displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName"));
    displayNameProperty.Value = "Edited Display Name";
    var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description"));
    descriptionProperty.Value = "Edited Description";
    var brandProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Brand"));
    brandProperty.Value = "Edited Brand";
    var manufacturerProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Manufacturer"));
    manufacturerProperty.Value = "Edited Manufacturer";
    var typeOfGoodProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("TypeOfGood"));
    typeOfGoodProperty.Value = "Edited TypeOfGood";
    var tagsProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Tags"));
    typeOfGoodProperty.Value = "['Tag1', 'Tag2', 'Tag3']";
  3. アクションを実行します。

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

販売可能商品の関連付けを解除する (C#)

次の例は、Entity Views and Actions APIを使用して、C# を使用してSellable商品の関連付け (カテゴリなど) を解除する方法を示しています。

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

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Category-{Category}",string.Empty, "DeleteSellableItem", "Entity-SellableItem-{SellableItemId}");
    EntityView view = Proxy.GetValue(query);
  2. Sellable商品の関連付けを解除します。

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

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