1. インベントリの統合

インベントリ エンティティ ビューとアクションAPIの操作

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

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

XC Inventory Entity Views and Actions APIを使用して、XC Inventoryの操作とデータを外部のビジネスシステムと統合できます。

メモ

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

インベントリ セットはプログラムで取得できます。クエリでは、インベントリ セットのID (inventorySetId) を指定する必要があります。

C# を使用してインベントリ セットを取得するには:

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

インベントリ セットの作成 (C#)

インベントリ セットはプログラムで作成できます。

新しいインベントリ セットを作成するには (C# などを使用して):

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

    DataServiceQuerySingle<EntityView> query = container.GetEntityView(string.empty, "Details", "AddInventorySet", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. インベントリ セットの詳細を指定します。要求では、新しいインベントリ セットの名前 (name)、表示名 (DisplayName)、および必要に応じて説明 (description) を指定する必要があります。

    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"));
        
    Name.Value = "NewSet";
    DisplayName.Value = "A New Inventory Set";
    Description.Value = "A brand new Inventory Set";
  3. アクションを実行します。

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

インベントリ セットの更新 (C#)

既存のインベントリセットの詳細を編集できます。

インベントリ セットの詳細を更新する (たとえば、表示名と説明を変更する) には、C# を使用して次の操作を行います。

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

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-InventorySet-{InventoryId}", "Details", "EditInventorySet", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. インベントリ セットの更新された詳細を提供します。

    var Description = view.Properties.FirstOrDefault(p => p.Name.Equals("Description"));
    var DisplayName = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName"));
        
    Description.Value = "A new Updated description"
    DisplayName.Value = "Changed Display Name";
  3. アクションを実行します。

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

在庫セットに品目を関連付ける (C#)

Sellable商品を指定した在庫セットに関連付けることができます。たとえば、Sellable商品が2つの在庫セットに関連付けられている場合、Sellable商品の100ユニットを在庫セットAに、40ユニットを在庫セットBに割り当てることができます。これにより、ニーズに応じて在庫を管理できます。

Sellable商品を在庫セットに関連付けるには (C# などを使用して):

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

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"",string.Empty,"DeleteCatalog", "Entity-Catalog-{CatalogId}");
    EntityView view = Proxy.GetValue(query);
  2. Sellable商品の在庫の詳細を設定します。

    var SellableItem = view.Properties.FirstOrDefault(p => p.Name.Equals("SellableItem"));
    //  System.String
    var Quantity = view.Properties.FirstOrDefault(p => p.Name.Equals("Quantity"));
    //  System.Int32
    var InvoiceUnitPrice = view.Properties.FirstOrDefault(p => p.Name.Equals("InvoiceUnitPrice"));
    //  System.Decimal
    var InvoiceUnitPriceCurrency = view.Properties.FirstOrDefault(p => p.Name.Equals("InvoiceUnitPriceCurrency"));
    //  System.String
    var Preorderable = view.Properties.FirstOrDefault(p => p.Name.Equals("Preorderable"));
     //  System.Boolean
    var PreorderAvailabilityDate = view.Properties.FirstOrDefault(p => p.Name.Equals("PreorderAvailabilityDate"));
    //  System.DateTimeOffset
    var PreorderLimit = view.Properties.FirstOrDefault(p => p.Name.Equals("PreorderLimit"));
    //  System.Int32
    var Backorderable = view.Properties.FirstOrDefault(p => p.Name.Equals("Backorderable"));
    //  System.Boolean
    var BackorderAvailabilityDate = view.Properties.FirstOrDefault(p => p.Name.Equals("BackorderAvailabilityDate"));
    //  System.DateTimeOffset
    var BackorderLimit = view.Properties.FirstOrDefault(p => p.Name.Equals("BackorderLimit"));
    //   System.Int32
        
        SellableItem.Value = $"Entity-SellableItem-{ItemToAssociate}";
        Quantity.Value = 10;
        InvoiceUnitPrice.Value = 20.00;
        InvoiceUnitPriceCurrency.Value = "USD";
        Preoderable.Valu = true;
        PreOrderAvailabilityDate.Value = DateTimeOffset.Now;
        PreorderLimit.Value = 2;
        Backorderable.Value = false;
        BackorderAvailabilityDate.Value = DateTimeOffset.Now;
        BackorderLimit.Value = 0;
  3. アクションを実行します。

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

在庫セットからの品目の関連付けの解除 (C#)

Sellable商品 (sellableItemId) または商品の特定のバリエーション (variationId) を在庫セットから削除できます。

Sellable商品などの商品を指定した在庫セットから関連付けを解除するには、次の手順に従います。

  1. エンティティ ビューを取得し、Sellable商品の関連付けを解除します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-InventorySet-{InventorySetId}",string.Empty,"DisassociateSellableItemFromInventorySet", "Entity-SellableItem-{SellableItemId}");
    EntityView view = Proxy.GetValue(query);
  2. アクションを実行します。

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

インベントリの転送 (C#)

Sellable商品のユニット数量を複数の在庫セット間で転送できます。たとえば、特定のSellable商品の100ユニットを在庫セットAに割り当て、40ユニットをセットBに割り当てたが、セットBが不足している場合、Sellableアイテムの追加量を在庫セットAから在庫セットBに転送できます。これにより、店舗や配送センターのさまざまなニーズに対応できます。

たとえば、C# を使用して、あるセットから別のセットにインベントリを転送するには:

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

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-InventorySet-{InventoryId}", "TransferInventory", "TransferInventory", $"Entity-SellableItem-{SellableItemId}");
    EntityView view = Proxy.GetValue(query);DataServiceQuerySingle<EntityView>; query = container.GetEntityView($"Entity-Category-{CategoryId}", "Details", "EditCategory", string.Empty);
    EntityView view = Proxy.GetValue(query);
  2. 転送するインベントリセットと数量を指定します。

    var InventorySet = view.Properties.FirstOrDefault(p => p.Name.Equals("InventorySet"));
    //  System.String
    var Quantity = view.Properties.FirstOrDefault(p => p.Name.Equals("Quantity"));
    //  System.Int32
    InventorySet.Value = $"Entity-InventorySet-{InventorySetToPullFrom}";
    Quantity.Value = 10;
  3. アクションを実行します。

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

カタログをインベントリ セットに関連付ける (C#)

カタログをインベントリーセットに関連付けることができます。

カタログをインベントリ セットに関連付けるには (たとえば、C# を使用して):

  1. エンティティ ビューを取得し、カタログを削除します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-InventorySet-{InventoryId}", "InventorySetCatalogs", "AssociateCatalog", string.Empty);
    EntityView view = Proxy.GetValue(query);DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-{ParentType}-{ParentId}",string.Empty,"DeleteCategory","Entity-Category-{CategoryId}");
    EntityView view = Proxy.GetValue(query);
  2. インベントリ セットに関連付けるカタログを指定します。

    var Catalog = view.Properties.FirstOrDefault(p => p.Name.Equals("CatalogName"));
    //  System.String
    Catalog.Value  = $"Entity-Catalog-{CatalogId}";
  3. アクションを実行します。

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

カタログとインベントリ セットの関連付けを解除する (C#)

カタログとインベントリセットの関連付けを解除できます。

カタログとインベントリ セットの関連付けを解除するには (たとえば、C# を使用して):

  1. エンティティ ビューを取得し、関連付けを解除するカタログIDを指定して指定します。

    DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-InventorySet-{InventoryId}", string.Empty, "DisassociateCatalog", {CatalogIdToDisassociate});
  2. アクションを実行します。

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