1. 製品同期

カスタム同期戦略を作成する

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

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

カスタム同期戦略を使うには:

  1. 新しいカスタムストラテジークラスを作成し、ISynchronizationStrategyインターフェースを実装します。

    このインターフェースには、同期の方向を受け入れるResolveメソッドと、外部システムおよびSitecoreからの基本プロダクトエンティティが含まれています。

    Resolveメソッドはどのシステム(theECSかSitecore)を更新するかを決定し、その結果を返します。

    namespace Sitecore.Commerce.Products { using Sitecore.Commerce.Entities.Products;

    ///

    /// The SynchronizationStrategy interface. ///

    public interface ISynchronizationStrategy { ///

    /// Resolves the specified direction. /// /// The direction. /// The external system entity. /// The entity from content management system. /// The place, where we decide if entity is updated.

    UpdateIn Resolve(Direction direction, ProductEntity externalSystemEntity, ProductEntity sitecoreEntity); } }

  2. Sitecore.Commerce.Products.configファイルにカスタム同期戦略クラスを登録します。

    これを行うには、synchronizationStrategy要素のタイプ属性値をカスタム同期戦略タイプに変更します。

The default DateTime based strategy that comes with Connect is the simplest possible strategy:

///

/// The synchronization strategy based on updated date of entity in external system and content management system.

///

public class DateTimeSynchronizationStrategy : ISynchronizationStrategy

{

///

/// Resolves the specified direction. /// /// The direction. /// The external system entity. /// The entity from content management system. /// /// The place, where we decide if entity is updated. ///

public UpdateIn Resolve(Direction direction, ProductEntity externalSystemEntity, ProductEntity sitecoreEntity) { if (string.IsNullOrEmpty(sitecoreEntity.ExternalId) && (direction == Direction.Both || direction == Direction.Inbound)) { return UpdateIn.Sitecore; } if (externalSystemEntity.Updated == sitecoreEntity.Updated) { return UpdateIn.None; } if (externalSystemEntity.Updated < sitecoreEntity.Updated) { if (direction == Direction.Both || direction == Direction.Outbound) { return UpdateIn.ExternalCommerceSystem; } } else { if (direction == Direction.Both || direction == Direction.Inbound) { return UpdateIn.Sitecore; } } return UpdateIn.None; } }

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