# Shopify Import Integration Shopify用のデータコネクタを使用して、ShopifyからTreasure Dataへ直接データをインポートできます。 Shopifyからデータをインポートする方法のサンプルワークフローについては、[Treasure Boxes](https://github.com/treasure-data/treasure-boxes/tree/master/td_load/shopify)をご覧ください。 # 前提条件 - Treasure Dataの基本的な知識 - Shopifyの基本的な知識 ## Shopify認証情報の取得 Shopify認証情報を取得するには、以下の手順を実行してください: 1. [https://www.shopify.com/](https://www.shopify.com/)でサインアップし、ユーザー用のオンラインストアを作成します。 2. ユーザーに関する詳細を入力します。 3. ビジネスに関する追加の詳細を入力します。 4. カスタムアプリを作成します。 5. ユーザーはAPI認証情報を確認し、保存して、さまざまな外部アプリケーションと接続することができます。 ## store_name設定 ShopifyはユーザーのStore NameをURL対応の値に変換します。たとえば、特殊文字を切り捨て、スペースをハイフンに置き換えます。 例: Example Shop-123-!#$ は example-shop-123 になります: ![](/assets/image2020-11-25_15-46-9.d1e34300a2d3e085fefa41de5061a2e81285047e5198c98de794acb5688e8c16.240488a1.png) 変換された値を使用する必要があります(サインイン後のAdmin URL内): ![](/assets/image2020-11-25_15-46-24.08a7272ce0f78946bc7208605de1c17931086d9605d15bbdb37983c9b7d37583.240488a1.png) ## TD Consoleを使用した接続の作成 ### 新しい接続の作成 1. **Integrations Hub** > **Catalog**に移動し、Shopifyを検索して選択します。 2. **Create**を選択します。認証された接続を作成しています。 ![](/assets/screen-shot-2019-11-16-at-12.07.39-pm.7c1a081729fee61cce5cc8cdf5fe521d5c42d1490460835098864cde6d8e687b.240488a1.png) 次のダイアログが開きます。Password値については、Shopifyコンソールの**Admin API access token**を確認してください。 ![](/assets/screen-shot-2019-11-16-at-12.08.47-pm.877d111a8b97ca07e802e9f170ecebf2d666925250978ae96e584023d794ce72.240488a1.png) 1. 必須フィールドを入力し、**Continue**を選択します。 2. 新しいShopify接続に名前を付けます。**Done**を選択します。 ### Treasure Dataへのデータ転送 認証された接続を作成すると、自動的にAuthenticationsタブに移動します。 ![](/assets/image-20200708-201126.0e761577b758dca083f31b4ef278b6ae53e731f6aee6178e63c796e59c5daed2.240488a1.png) 1. 作成した接続を探し、**New Source**を選択します。以下のフィールドを編集します。 | フィールド | 説明 | | --- | --- | | **Source** | Shopifyから転送するオブジェクトのタイプ(products、customers、transactions、orders、inventory、metafieldsなど)。以下のリストでサポートされている要素を確認できます: - Objects - inventory level - inventory_items - location - Order status - open - closed - canceled - any - Metafields resource - product - customer - order - online_store - shop - Product resource objects - product - product_variant - product_image - collection - Order resource objects - order - draft_order - Online_store resource objects - blog - article - page | | **Incremental** | Treasure Dataにデータを増分的にロードします。この選択により、Incremental field**が有効になります。** | | **Incremental field** | オブジェクトのソートに使用されるデータフィールド。created_atとupdated_atの2つのオプションがあります。 | | **Data type** | メタデータオブジェクトのソートに使用されるデータフィールド。created_atとupdated_atの2つのオプションがあります。 | | **Start date** | 'start_date'を定義することで、'start_date'以降に作成または更新されたオブジェクトのみを選択できます。このフィールドはIncremental fieldに依存します。incrementalがfalseに設定されている場合、products、customers、transactions、ordersオブジェクトからインポートする際に、created_atがStart dateのターゲットとして扱われます | | **Use precise 'End date'** | **End date**を指定するか、空白のままにします。 | | **Number of days to fetch** | 'start_date'から何日分のデータを取得するかを指定します。 | | **End date** | オブジェクトが更新された日付を指定します: - **End date**が指定されていない場合、現在までのすべてのオブジェクトが取得されます。 - **Start time**と**End time**を組み合わせて、'start_date'から'end_date'までの特定の期間を指定できます。 | | **Inventory Item IDs** | inventory_idsのリスト。 | | **Location IDs** | location_idsのリスト。 | | **Updated at** | 指定された時刻から現在まで、`inventory_level`オブジェクトがupdated_atされた時刻。 | | **Fetch all customer's metafields** | すべての顧客のmetafieldsをダウンロード | 1. データをプレビューします。変更するには、**Advanced Settings**を選択します。そうでない場合は**Next**を選択します。 ![](/assets/screen-shot-2019-11-16-at-12.16.12-pm.5709abe26d10772f4a5b5927db3545e6103b799745be13e8ea82bdb5f38fd6e3.240488a1.png) 1. データを転送するデータベースとテーブルを選択します。 ![](/assets/screen-shot-2019-11-16-at-12.19.27-pm.85d36ab90c39a1e285d5642d19a46653bb157a8f655ac300feb5ee48b31c7f3c.240488a1.png) 1. 次のダイアログを使用してデータ転送のスケジュールを指定し、**Next**を選択します。 ![](/assets/screen-shot-2019-11-16-at-12.21.49-pm.f8cbc1b5834f02af93857afd3f49fceed03578c63c990da41cf75673b087869b.240488a1.png) 1. ソースに名前を付けて、**Done**を選択します。 ![](/assets/screen-shot-2019-11-16-at-12.23.03-pm.4852f8b98949f26e9a59d74e24d1991e9aacb713db39db14e87ac25e14e72018.240488a1.png)