ミニオン パイプラインの構成
Version:
日本語翻訳に関する免責事項
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
インデックス ミニオン パイプラインに特定のブロックを追加して、さまざまなインデックス ミニオンが各タイプのエンティティを適切に処理できるようにする必要があります。
フル インデックス ミニオンとインクリメンタル インデックス ミニオン パイプライン
ブロックをIFullIndexMinionPipelineとIncrementalIndexMinionPipelineにそれぞれ挿入して、インデックスを作成するエンティティの種類ごとにドキュメント ビューを作成します。
InitializeOrdersIndexingViewBlock (Ordersプラグイン内) またはInitializeCustomersIndexingViewBlock (Customersプラグイン内) を参照として使用できます。
public override Task<EntityView> Run(EntityView arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: argument cannot be null."); var argument = context.CommerceContext.GetObjects<SearchIndexMinionArgument>().FirstOrDefault(); if (string.IsNullOrEmpty(argument?.Policy?.Name)) { return Task.FromResult(arg); } var orders = argument.Entities?.OfType<Order>().ToList(); if (orders == null || !orders.Any()) { return Task.FromResult(arg); } var searchViewNames = context.GetPolicy<KnownSearchViewsPolicy>(); orders.ForEach( order => { var documentView = arg.ChildViews.Cast<EntityView>() .FirstOrDefault(v => v.EntityId.Equals(order.Id, StringComparison.OrdinalIgnoreCase) && v.Name.Equals(searchViewNames.Document, StringComparison.OrdinalIgnoreCase)); if (documentView == null) { documentView = new EntityView { Name = context.GetPolicy<KnownSearchViewsPolicy>().Document, EntityId = order.Id }; arg.ChildViews.Add(documentView); } var email = string.Empty; var customerId = string.Empty; if (order.HasComponent<ContactComponent>()) { var contactComponent = order.GetComponent<ContactComponent>(); email = string.IsNullOrEmpty(contactComponent.Email) ? string.Empty : contactComponent.Email; customerId = string.IsNullOrEmpty(contactComponent.CustomerId) ? string.Empty : contactComponent.CustomerId; } documentView.Properties.Add(new ViewProperty { Name = "EntityId", RawValue = Guid.Parse(order.Id).ToString("D") }); documentView.Properties.Add(new ViewProperty { Name = "Email", RawValue = email }); documentView.Properties.Add(new ViewProperty { Name = "CustomerId", RawValue = customerId }); documentView.Properties.Add(new ViewProperty { Name = "Status", RawValue = order.Status }); documentView.Properties.Add(new ViewProperty { Name = "OrderConfirmationId", RawValue = order.OrderConfirmationId }); documentView.Properties.Add(new ViewProperty { Name = "OrderPlacedDate", RawValue = order.OrderPlacedDate }); documentView.Properties.Add(new ViewProperty { Name = "DateCreated", RawValue = order.DateCreated }); documentView.Properties.Add(new ViewProperty { Name = "DateUpdated", RawValue = order.DateUpdated }); documentView.Properties.Add(new ViewProperty { Name = "ArtifactStoreId", RawValue = context.CommerceContext.Environment.ArtifactStoreId }); }); return Task.FromResult(arg); }
検索ビュー パイプライン
Search Results (検索結果) ビューを変更する場合は、(SearchViewポリシーで指定されたタグに基づいて) SearchPipelineにブロックを追加して、検索結果にデータを追加できます。
(Ordersプラグインの) ProcessDocumentSearchResultBlockを参照として使用できます。
public override async Task<EntityView> Run(EntityView arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: argument can not be null."); var documents = context.CommerceContext.GetObjects<List<Document>>().FirstOrDefault(); if (documents == null || !documents.Any()) { return arg; } if (!arg.HasPolicy<SearchScopePolicy>()) { return arg; } var scope = arg.GetPolicy<SearchScopePolicy>(); var hasTags = scope.ResultDetailsTags.Any(t => t.Name.Equals("OrdersList")); if (!hasTags) { return arg; } foreach (var document in documents) { var docId = document["EntityId".ToLowerInvariant()].ToString(); var child = arg.ChildViews.OfType<EntityView>().FirstOrDefault(c => c.EntityId.Equals(docId, StringComparison.OrdinalIgnoreCase)); if (child == null) { continue; } Guid orderGuid; if (!Guid.TryParse(docId, out orderGuid)) { continue; } var orderId = orderGuid.ToString("B"); var order = await this._findPipeline.Run(new FindEntityArgument(typeof(CommerceEntity), orderId), context) as Order; if (order == null) { continue; } var entityId = child.Properties.FirstOrDefault(p => p.Name.Equals("EntityId", StringComparison.OrdinalIgnoreCase)); if (entityId != null) { entityId.RawValue = orderId; entityId.UiType = string.Empty; entityId.IsHidden = true; } var confirmationId = child.Properties.FirstOrDefault(p => p.Name.Equals("OrderConfirmationId", StringComparison.OrdinalIgnoreCase)); if (confirmationId != null) { confirmationId.UiType = "EntityLink"; } var customerId = child.Properties.FirstOrDefault(p => p.Name.Equals("CustomerId", StringComparison.OrdinalIgnoreCase)); if (customerId != null && order.HasComponent<ContactComponent>()) { var contact = order.GetComponent<ContactComponent>(); if (contact.IsRegistered) { customerId.UiType = "Html"; var value = customerId.RawValue.ToString(); customerId.RawValue = $"<a href=\"/entityView/Master/{value}\">{contact.Email}</a>"; } else { customerId.RawValue = contact.Email; } } var status = child.Properties.FirstOrDefault(p => p.Name.Equals("Status", StringComparison.OrdinalIgnoreCase)); var total = new ViewProperty { Name = "total", RawValue = order.Totals.GrandTotal, IsReadOnly = true }; var placedDate = child.Properties.FirstOrDefault(p => p.Name.Equals("OrderPlacedDate", StringComparison.OrdinalIgnoreCase)); var updatedDate = child.Properties.FirstOrDefault(p => p.Name.Equals("DateUpdated", StringComparison.OrdinalIgnoreCase)); child.EntityId = orderId; child.ItemId = orderId; child.Properties.Clear(); child.Properties.Add(confirmationId); child.Properties.Add(customerId); child.Properties.Add(status); child.Properties.Add(total); child.Properties.Add(placedDate); child.Properties.Add(updatedDate); } return arg; }