# Optimizely Customized CommerceとOptimizely Product Information Managementの統合

### PIM によるカスタマイズされたコマース統合 <a href="#gjdgxs" id="gjdgxs"></a>

このトピックでは、Optimizely Customized Commerce 用に Optimizely 製品情報管理 (PIM) をインストールして構成する方法について説明します。 PIM 統合により、詳細な製品情報を管理し、データを Customized Commerce に同期できます。

### PIMについて <a href="#id-30j0zll" id="id-30j0zll"></a>

PIM は、サイズ、重量、色、関連画像などの商品情報を含む、コマース サイトの詳細な製品情報を簡単に管理できるように構築されています。 カタログと製品データの要件をすばやく設定し、データの取得とキュレーションのプロセスを効率的に管理できます。

以下の図は、PIM がスケジュールされたジョブを使用してデータを受信、更新、承認し、Customized Commerce に渡すことによってデータを処理する方法を示しています。

![PIM-B2C\_data\_flow.png](/files/u47SJL0oN9NrQZ2cvdRv)

### インストールと設定 <a href="#id-1fob9te" id="id-1fob9te"></a>

PIM 統合を追加するには、 [EPiServer.Commerce.PIM ](https://nuget.episerver.com/package/?id=EPiServer.Commerce.PIM)NuGet パッケージを Optimizely Customized Commerce サイトにインストールします。

EPiServer.Commerce.PIM統合 NuGet パッケージに&#x306F;**、**&#x30C7;ータ同期用のスケジュールされたジョブのセットが含まれています。

#### **構成設定** <a href="#id-3znysh7" id="id-3znysh7"></a>

パッケージをインストールした後、 *web.config*または*appsettings.json*ファイルの \<appSettings> セクションにこれらの構成設定を追加し、次のように値を定義します。

**ウェブ構成**

```
<appSettings>
  <add key="episerver:PIM.Environment" value="" />
  <add key="episerver:PIM.ClientId" value="" />
  <add key="episerver:PIM.ClientSecret" value="" />
  <add key="episerver:PIM.NumberOfLookbackDays" value="" />
  <add key="episerver:PIM.APIAddress" value="" />
  <add key="episerver:PIM.TokenEndpoint" value="" />
</appSettings>
```

**アプリ設定.json**

```
"Commerce": {
  "PIMOptions": {
     "Environment": "",
     "AppKey": "",
     "SecretKey": "",
     "NumberOfLookbackDays": "",
     "APIAddress": ""
  }
}
```

#### **設定キー** <a href="#id-2et92p0" id="id-2et92p0"></a>

| キー                                 | 説明                                                                                                                                                  |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| episerver:PIM.Environment          | <p>値: <strong>Production</strong>または<strong>Sandbox</strong> 。<br>現在のサイト環境の設定。</p><p><strong>PIM > 構成 > 設定 > アクティブ公開環境</strong>の設定と一致する必要があります。</p> |
| episerver:PIM.ClientId             | PIM API に接続するためのクライアント ID キー。                                                                                                                       |
| episerver:PIM.ClientSecret         | PIM API に接続するためのクライアント秘密キー。                                                                                                                         |
| episerver:PIM.NumberOfLookbackDays | 公開日に基づいて製品レコードを取得するために**更新モード**で使用される日数。 デフォルト値は**5 日です**。                                                                                          |
| episerver:PIM.APIAddress           | PIM API エンドポイントのルート URL。                                                                                                                            |

### スケジュールされたジョブ <a href="#id-3dy6vkm" id="id-3dy6vkm"></a>

PIM 統合パッケージには、Customized Commerce とのデータ同期を管理するための 3 つのスケジュールされたジョブのセットが含まれています。 [スケジュールされたジョブは、 ](https://docs.developers.optimizely.com/content-management-system/docs/scheduled-jobs)**CMS 管理ビュー**から管理されます。

#### **セットアップデータを同期する** <a href="#id-1t3h5sf" id="id-1t3h5sf"></a>

**PIM: セットアップ データを同期すると、**&#x30AB;タログと製品タイプに関する情報が PIM にプッシュされます。 カスタマイズされたコマース属性 (PIMSync など) を持つコンテンツ タイプまたはプロパティに変更を加えた場合は、必ずこのジョブを実行する必要があります。 新しい言語、Web サイト、関係タイプ、または製品のカスタム プロパティが追加された場合も含め、パートナー QA サイトではなく、**サンドボックス**または**本番インスタンス**からジョブを実行します。

#### **承認された製品を公開する** <a href="#id-4d34og8" id="id-4d34og8"></a>

**PIM: 承認済み製品の公開は、承認済み製品をサンドボックス**(プロジェクトの初期段階) または**本番環境(ライブ後)**&#x306E;いずれかのアクティブな環境に取り込む必要があるときにいつでも実行する必要があります。 ステータスが「承認済み」の製品を取り込み、PIM 内のステータスを公開済みに更新します。 ジョブは通常、定期的に実行されるように設定されますが、オンデマンドで実行することもできます。

#### **公開済み製品を更新する** <a href="#id-2s8eyo1" id="id-2s8eyo1"></a>

**PIM: 公開された製品を更新すると、**&#x5FC5;要に応じて非本番環境が PIM と同期された状態になります。 ジョブ内の**ルックバック日数パラメータ**を使用して、公開済みのステータスの製品をプルし、ジョブを実行している環境に最後に公開された日付に基づいてプルします。 開発環境にも使用できます。 通常はオンデマンドでのみ実行する必要があります。

### PIMからコンテンツをインポートする <a href="#id-17dp8vu" id="id-17dp8vu"></a>

PIM から特定の種類のコンテンツを作成するためのロジックを追加できます。

#### **ノードを作成する** <a href="#id-3rdcrjn" id="id-3rdcrjn"></a>

カテゴリ/ノードの作成をオーバーライドするには、ICategoryNodeFactory インターフェイスを実装します。 新しいノードのプロパティを設定するには、IContentEvents.PublishingContent を使用します。

例:

```
public class CustomNodeContent : NodeContent { }

public class CustomCategoryNodeFactory : ICategoryNodeFactory
{
	private readonly IContentRepository _contentRepository;

	public CustomCategoryNodeFactory(IContentRepository contentRepository) => _contentRepository = contentRepository;

	public NodeContent Create(NodeContentBase parentNodeContent) => _contentRepository.GetDefault<CustomNodeContent>(parentNodeContent.ContentLink, parentNodeContent.MasterLanguage);
}

//Register your custom node factory  
services.AddSingleton<ICategoryNodeFactory, MyCustomCategoryNodeFactory>();
```

#### **メディアファイルを作成する** <a href="#id-26in1rg" id="id-26in1rg"></a>

メディア ファイルと画像ファイルの作成をオーバーライドするには、インターフェイス IMediaFileFactory を実装します。 新しいインスタンスのプロパティを設定するには、IContentEvents.PublishingContent を使用します。

例:

```
public class CustomCommerceImageFile : CommerceImageFile { }

public class CustomCommerceMediaFile : CommerceMediaFile { }

public class CustomMediaFileFactory : IMediaFileFactory
{
	private readonly IContentRepository _contentRepository;

	public CustomMediaFileFactory(IContentRepository contentRepository) => _contentRepository = contentRepository;

	public CommerceImageFile CreateImageFile(ContentReference folderLink, string name) => _contentRepository.GetDefault<CustomCommerceImageFile>(folderLink);

	public CommerceMediaFile CreateMediaFile(ContentReference folderLink, string name) => _contentRepository.GetDefault<CustomCommerceMediaFile>(folderLink);
}

//Register your custom media file factory  
services.AddSingleton<IMediaFileFactory, MyCustomMediaFileFactory>();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.dxable.com/optimizely/platform/optimizely-product-integrations/customized-commerce-+-pim-integration/optimizely-customized-commerce-integration-with-optimizely-product-information-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
