4

古いオンラインストアには30万人以上のユーザーがいます。クライアントはMagentoソリューションに切り替え、すべてのユーザー、アドレスをMagentoに移行する必要があります。そのため、ユーザーとそのアドレスをMagentoシステムにインポートするカスタムスクリプトを作成する必要があります。

チュートリアルや同様の作業がすでに行われていますか。私を助けてください。

ありがとう

4

2 に答える 2

3

これは、SOAPライブラリを使用してユーザーをOSCからMagentoに移行する方法の例です。このスクリプトは古いサーバーで実行されており、sshコマンドラインから実行する必要があります(ブラウザーを介したphpの実行時間はこれをサポートしません

    $proxy = new SoapClient('http://[your magento url]/api/soap/?wsdl=1');
    $sessionId = $proxy->login('admin', '[your password]');

    // connect to local db

    $link = mysql_connect('localhost', '[old ecommerce db]', '[old db pw]');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }

    mysql_select_db('sbc_osc', $link);

    $sql = "SELECT * FROM customers";

    $customers = mysql_query($sql);

    // loop thyrough customers
    while ($customer = mysql_fetch_assoc($customers)) {

        set_time_limit(600);

        $newCustomer = array(
            'firstname'  => $customer['customers_firstname'],
            'lastname'   => $customer['customers_lastname'],
            'email'      => $customer['customers_email_address'],
            'password_hash' => $customer['customers_password'],
            'store_id'   => 2, // set the store you want to send to
            'website_id' => 2
        );

        $telephone = $customer['customers_telephone'];
        $fax = $customer['customers_fax'];

        try{
            $newCustomerId = $proxy->call($sessionId, 'customer.create', array($newCustomer));
        }
        catch (Exception $e) {
            echo "failed to create customer for: " . $customer['customers_firstname'] . " " . $customer['customers_lastname'] . "\n";
        }

        // grab the default address
        $sql = "SELECT ab.*, c.countries_iso_code_2, z.zone_name, z.zone_id
                FROM address_book ab 
                LEFT JOIN countries c ON ab.entry_country_id =  c.countries_id
                LEFT JOIN zones z ON ab.entry_zone_id = z.zone_id
                WHERE customers_id = {$customer['customers_id']} AND address_book_id = {$customer['customers_default_address_id']}";

        $addresses = mysql_query($sql);

        while ($address = mysql_fetch_assoc($addresses)) {

            $newCustomerAddress = array(
                'firstname'  => $address['entry_firstname'],
                'lastname'   => $address['entry_lastname'],
                'company'    => $address['entry_company'],
                'country_id' => $address['countries_iso_code_2'],
                'region_id'  => $address['zone_id'],
                'region'     => ($address['zone_name'] != "" ? $address['zone_name'] : $address['entry_state']),
                'city'       => $address['entry_city'],
                'street'     => array($address['entry_street_address']),
                'telephone'  => $telephone,
                'fax'        => $fax,
                'postcode'   => $address['entry_postcode'],
                'is_default_billing'  => true,
                'is_default_shipping' => true,
            );

            try{
                $newAddressId = $proxy->call($sessionId, 'customer_address.create', array($newCustomerId, $newCustomerAddress));
            }
            catch (Exception $e) {
                echo "failed to add address for: " . $address['entry_firstname'] . " " . $address['entry_lastname'] . "\n";
            }
        }

        echo "migrated: " . $customer['customers_firstname'] . " " . $customer['customers_lastname'] . "\n";

    }


    mysql_close($link);

注意する必要があるのはパスワードです。これを機能させるには、同じパスワードハッシュスキーマを使用するようにMagentoを設定する必要がありました。

于 2011-01-20T13:34:20.347 に答える
1

私の提案は、顧客のインポートAPIを調べて、コードベースのメソッドを使用してスクリプトをビルドすることです。APIの使用は遅くなるため、サーバーでスクリプトを実行するため、実際のメソッドを使用してスクリプトをビルドできます。したがって、このフォルダーでカスタマーAPIクラスとメソッドを確認できます

/ app / code / core / Mage / Customer / Model / Customer

次に、アドレスapiクラスとメソッドについて説明します

/ app / code / core / Mage / Customer / Model / Address /

おそらく、データをCSVにエクスポートし、Magentoにインポートするための正しい形式で取得する必要があります。30kはそれほど多くないので、デフォルトのMagentoである通常のインポートプロセスを試すこともできます。幸運はありませんでしたが、何十万もの顧客を輸入してきました。それでも、ファイルを一度に小さな顧客の塊に分割します。

于 2011-01-20T12:43:28.227 に答える