[僅限PaaS]{class="badge informative" title="僅適用於雲端專案(Adobe管理的PaaS基礎結構)和內部部署專案的Adobe Commerce 。"}

設定Data Migration Tool

安裝Data Migration Tool之後,下列目錄包含對應和組態檔:

  • Magento Open Source:

    • <your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/opensource-to-opensource:從Magento Open Source 1移轉至Magento Open Source 2的設定和指令碼
  • Adobe Commerce:

    • <your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/opensource-to-commerce:從Magento Open Source 1移轉至Adobe Commerce 2的設定和指令碼
    • <your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/commerce-to-commerce:從Adobe Commerce 1移轉至Adobe Commerce 2的設定和指令碼

上述目錄包含每個支援版本的子目錄。

設定移轉

有兩種方法可設定Data Migration Tool:

  • 在個別模組中設定Data Migration Tool (建議)
  • 變更Data Migration Tool目錄中的<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/組態。

若要使用原始檔控制來管理您的移轉設定並用於部署,您必須建立個別的模組。
如果您只打算在本機執行Data Migration Tool,可以直接編輯<your Magento 2 install dir>/vendor/magento/data-migration-tool/目錄中的檔案。

在個別模組中設定移轉

移轉任何資料之前,您必須建立Magento 2模組。

  1. 建立Magento 2模組。

    • <your Magento 2 install dir>/app/code/Vendor/Migration/composer.json
    code language-json
    {
        "name": "vendor/migration",
        "description": "Providing config for migration",
        "config": {
            "sort-packages": true
        },
        "require": {
            "magento/framework": "*",
            "magento/data-migration-tool": "*"
        },
        "type": "magento2-module",
        "autoload": {
            "files": [
                "registration.php"
            ],
            "psr-4": {
                "Vendor\\Migration\\": ""
            }
        },
        "version": "1.0.0"
    }
    
    • <your Magento 2 install dir>/app/code/Vendor/Migration/registration.php
    code language-php
    <?php
    
    \Magento\Framework\Component\ComponentRegistrar::register(
        \Magento\Framework\Component\ComponentRegistrar::MODULE,
        'Vendor_Migration',
        __DIR__
    );
    
    • <your Magento 2 install dir>/app/code/Vendor/Migration/etc/module.xml
    code language-xml
    <?xml version="1.0"?>
    
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
        <module name="Vendor_Migration" setup_version="1.0.0">
            <sequence>
                <module name="Magento_DataMigrationTool"/>
            </sequence>
        </module>
    </config>
    
  2. config.xml.dist組態檔從Data Migration Tool (<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/<migration edition>/<ce or version>)的適當目錄複製到<your Magento 2 install dir>/app/code/Vendor/Migration/etc/<migration edition>/<ce or version>/config.xml檔案中。

    例如,如果您將Magento 1.9.3.6 Community Edition移轉至Magento 2 Open Source

    code language-bash
    cd <your Magento 2 install dir>
    
    code language-bash
    cp vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.6/config.xml.dist app/code/Vendor/Migration/etc/opensource-to-opensource/1.9.3.6/config.xml
    
  3. config.xml檔案中,您必須設定M1和M2資料庫的存取詳細資訊以及加密金鑰。

  4. 如果您的M1存放區有自訂變更,則應將其餘設定檔案對應至Magento 1存放區自訂。 請參閱使用組態和對應檔案

vendor資料夾中設定移轉

移轉任何資料之前,您必須從提供的範例建立config.xml設定檔。

若要設定Data Migration Tool進行移轉:

  1. 以或切換至檔案系統擁有者的身份登入您的應用程式伺服器。

  2. 變更至下列目錄:

    code language-bash
    <your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/<migration edition>/<ce or version>
    
  3. 輸入下列命令,從提供的範例建立config.xml

    code language-bash
    cp config.xml.dist config.xml
    
  4. 在文字編輯器中開啟config.xml

  5. config.xml檔案至少必須包含M1和M2資料庫的存取詳細資訊以及加密金鑰。

    code language-xml
    <source>
       <database host="127.0.0.1" name="magento1" user="root"/>
    </source>
    <destination>
       <database host="127.0.0.1" name="magento2" user="root"/>
    </destination>
    <options>
       <crypt_key />
    </options>
    

    <crypt_key>標籤必須包含值。 您可以在<key>標籤中找到它,該標籤位於您Magento 1執行個體上的app/etc/local.xml檔案中。

    選用引數:

    • 資料庫使用者密碼: password=<password>
    • 資料庫自訂連線埠: port=<port>
    • 資料表首碼: <source_prefix><dest_prefix>

    例如,如果您的資料庫擁有者使用者名稱是密碼為rootpass,而您在Magento 1資料庫中使用前置詞magento1,請在config.xml中使用下列專案:

    code language-xml
    <source>
       <database host="127.0.0.1" name="magento1" user="root" password="pass"/>
    </source>
    <destination>
       <database host="127.0.0.1" name="magento2" user="root" password="pass"/>
    </destination>
    <options>
       <source_prefix>magento1</source_prefix>
       <crypt_key>f3e25abe619dae2387df9fs594f01985</crypt_key>
    </options>
    

完成後,將您的變更儲存至config.xml並結束文字編輯器。

使用TLS通訊協定連線

您也可以使用TLS通訊協定(亦即使用公開/私用密碼編譯金鑰)連線到資料庫。 將下列選擇性屬性新增至database元素:

  • ssl_ca
  • ssl_cert
  • ssl_key

例如:

<source>
    <database host="localhost" name="magento1" user="root" ssl_ca="/path/to/file" ssl_cert="/path/to/file" ssl_key="/path/to/file"/>
</source>
<destination>
    <database host="localhost" name="magento2" user="root" ssl_ca="/path/to/file" ssl_cert="/path/to/file" ssl_key="/path/to/file"/>
</destination>

使用設定和對映檔案

Data Migration Tool使用​ 對應檔案,讓您在Magento 1與Magento 2資料庫之間執行自訂資料庫對應,包括:

  • 變更表格名稱

  • 變更欄位名稱

  • 忽略表格或欄位

  • 將欄位的傳輸資料調整為Magento 2格式

受支援Magento版本的對應檔案位於<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc的子目錄中

若要使用對應檔案:

  1. 將它們從<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/<migration edition>/<ce or version>/複製到<your Magento 2 install dir>/app/code/Vendor/Migration/etc/<migration edition>/<ce or version>/並移除.dist副檔名。

  2. 更新<options>config.xml節點中新複製的檔案的路徑。 更新的路徑應為下列其中一項:

    1. 絕對檔案路徑,例如/var/www/html/app/code/Vendor/Migration/etc/opensource-to-opensource/1.9.4.1/map.xml
    2. magento/data-migration-tool模組相對檔案路徑: etc/opensource-to-opensource/1.9.4.1/map.xml
    3. Magento根目錄相對檔案路徑: app/code/Vendor/Migration/etc/opensource-to-opensource/1.9.4.1/map.xml

<Magento 2 dir>/vendor/magento/data-migration-tool/etc<Magento 2 dir>/vendor/magento/data-migration-tool/etc/<ce version>目錄包含下列組態檔:

即使您大部分時間都在使用map.xml.dist檔案,下表仍討論每個對應和其他檔案。

對應檔案名稱
說明
class-map.xml.dist
Magento 1與Magento 2之間類別對應的字典
config.xml.dist
主要設定檔,其會指定Magento 1和Magento 2資料庫設定、步驟設定,以及對應檔案的連結
僅限Adobe Commercecustomer-attr-document-groups.xml.dist
自訂客戶屬性步驟中使用的表格清單。
僅限Adobe Commercecustomer-attr-map.xml.dist
對應自訂客戶屬性步驟中所使用的檔案。
deltalog.xml.dist
包含資料庫常式設定所需的表格清單。
eav-attribute-groups.xml.dist
包含「執行步驟」中所使用的屬性清單。
eav-document-groups.xml.dist
包含執行步驟中所使用的表格清單。
log-document-groups.xml.dist
包含記錄步驟中使用的表格清單。
map-eav.xml.dist
EAV步驟中使用的對應檔案。
map-log.xml.dist
記錄對應檔案。
僅限Adobe Commercemap-sales.xml.dist
SalesOrder Step中使用的對應檔案。
map.xml.dist
對應步驟所需的對應檔案。
settings.xml.dist
設定移轉組態檔,指定移轉core_config_data資料表所需的規則。
customer-attribute-groups.xml.dist
包含用於客戶屬性步驟的屬性清單。
customer-document-groups.xml.dist
包含用於客戶屬性步驟中的表格清單。
map-customer.xml.dist
對應客戶屬性步驟中所使用的檔案。
order-grids-document-groups.xml.dist
包含用於OrderGrids步驟的表格清單。
map-document-groups.xml.dist
定義資料插入時發生重複時更新的欄位
map-stores.xml.dist
對應用於商店步驟的檔案。
map-tier-price.xml.dist
用於層級價格步驟的對映檔案。
僅限Adobe Commercevisual_merchandiser_map.xml.dist
VisualMerchandiser步驟中使用的對應檔案。
僅限Adobe Commercevisual_merchandiser_attribute_groups.xml.dist
包含用於VisualMerchandiser步驟的屬性清單。
僅限Adobe Commercevisual_merchandiser_document_groups.xml.dist
包含用於VisualMerchandiser步驟的表格清單。

如需詳細資訊,請參閱Data Migration Tool 技術規格

recommendation-more-help
c2d96e17-5179-455c-ad3a-e1697bb4e8c3