もしもドロップシッピングをECCubeを使って管理したい(1)
このご時世、ちょっとでもお金を稼ごうと思いまして、もしもドロップシッピングをECCubeを利用して管理しようと考えました。
今回は、商品データベースにデータを入れます。
-- ダウンロードしたデータをインポートするテーブル CREATE TABLE articles ( goods_id integer NOT NULL, -- 商品ID goods_name text, category_name text, tag_name text, maker_name text, goods_number text, wholesale_price integer, low_price integer, selling_price integer, recommended_price integer, catch_copy text, shop_explain text, goods_explain text, spec text, image_code text, image_num integer, same_parcel text, settlement_method text, last_update timestamp with time zone, CONSTRAINT articles_pkey PRIMARY KEY (goods_id) ) -- ECCube対応のCSV出力を行うために利用するテーブル CREATE TABLE wrk_articles ( c001 text NOT NULL, c002 text, c003 text, c004 text, c005 text, c006 text, c007 text, c008 text, c009 text, c010 text, c011 text, c012 text, c013 text, c014 text, c015 text, c016 text, c017 text, c018 text, c019 text, c020 text, c021 text, c022 text, c023 text, c024 text, c025 text, c026 text, c027 text, c028 text, c029 text, c030 text, c031 text, c032 text, c033 text, c034 text, c035 text, c036 text, c037 text, c038 text, c039 text, c040 text, c041 text, c042 text, c043 text, c044 text, c045 text, c046 text, c047 text, c048 text, c049 text, c050 text, c051 text, c052 text, c053 text, c054 text, c055 text, c056 text, c057 text, c058 text, CONSTRAINT wrk_articles_pkey PRIMARY KEY (c001) )
手順
1.もしもドロップシッピングよりデータ(articles.csv)をダウンロードする(https://www.moshimo.com/shop/download#specific-url-article-image)
2.articles.csvをインポート
set client_encoding to ‘SJIS′; COPY articles FROM E'C:\\tmp\\articles.txt' with CSV;
3.ワークテーブルにデータを挿入する
INSERT INTO wrk_articles( c001, c002, c003, c004, c005, c006, c007, c008, c009, c010, c011, c012, c013, c014, c015, c016, c017, c018, c019, c020, c021, c022, c023, c024, c025, c026, c027, c028, c029, c030, c031, c032, c033, c034, c035, c036, c037, c038, c039, c040, c041, c042, c043, c044, c045, c046, c047, c048, c049, c050, c051, c052, c053, c054, c055, c056, c057, c058) SELECT goods_id as c001 , -- 商品ID goods_id goods_number as c002 , -- 商品規格ID goods_number null as c003 , -- 規格名1 null as c004 , -- 規格名2 goods_name as c005 , -- 商品名(※ 必須) goods_name null as c006 , -- 公開フラグ(1:公開 2:非公開)(※ 必須) null as c007 , -- 商品ステータス(※ 必須) null as c008 , -- 商品コード recommended_price as c009 , -- 通常価格 recommended_price selling_price as c010 , -- 販売価格(※ 必須) selling_price null as c011 , -- 在庫数 null as c012 , -- 送料 null as c013 , -- ポイント付与率(※ 必須) null as c014 , -- 購入制限 maker_name as c015 , -- メーカーURL maker_name null as c016 , -- 検索ワード tag_name null as c017 , -- 備考欄(SHOP専用) shop_explain,wholesale_price,low_price,image_num catch_copy as c018 , -- 一覧-メインコメント(※ 必須) catch_copy 'http://image.moshimo.com/item_image/'||image_code||'/1/m.jpg' as c019 , -- 一覧-メイン画像(※ 必須) http://image.moshimo.com/item_image/image_code/1/m.jpg goods_explain as c020 , -- メインコメント(※ 必須) goods_explain 'http://image.moshimo.com/item_image/'||image_code||'/1/m.jpg' as c021 , -- メイン画像(※ 必須) http://image.moshimo.com/item_image/image_code/1/m.jpg 'http://image.moshimo.com/item_image/'||image_code||'/1/l.jpg' as c022 , -- メイン拡大画像 http://image.moshimo.com/item_image/image_code/1/l.jpg null as c023 , -- カラー比較画像 null as c024 , -- 商品詳細ファイル 'スペック' as c025 , -- 詳細-サブタイトル(1) スペック spec as c026 , -- 詳細-サブコメント(1) spec null as c027 , -- 詳細-サブ画像(1) null as c028 , -- 詳細-サブ拡大画像(1) '同梱可否' as c029 , -- 詳細-サブタイトル(2) 同梱可否 'same_parcel' as c030 , -- 詳細-サブコメント(2) same_parcel null as c031 , -- 詳細-サブ画像(2) null as c032 , -- 詳細-サブ拡大画像(2) '決済方法' as c033 , -- 詳細-サブタイトル(3) "決済方法 " settlement_method as c034 , -- 詳細-サブコメント(3) settlement_method null as c035 , -- 詳細-サブ画像(3) null as c036 , -- 詳細-サブ拡大画像(3) '最終更新日時' as c037 , -- 詳細-サブタイトル(4) 最終更新日時 last_update as c038 , -- 詳細-サブコメント(4) last_update null as c039 , -- 詳細-サブ画像(4) null as c040 , -- 詳細-サブ拡大画像(4) null as c041 , -- 詳細-サブタイトル(5) null as c042 , -- 詳細-サブコメント(5) null as c043 , -- 詳細-サブ画像(5) null as c044 , -- 詳細-サブ拡大画像(5) null as c045 , -- 発送日目安 null as c046 , -- おすすめ商品(1) null as c047 , -- 詳細-サブコメント(1) null as c048 , -- おすすめ商品(2) null as c049 , -- 詳細-サブコメント(2) null as c050 , -- おすすめ商品(3) null as c051 , -- 詳細-サブコメント(3) null as c052 , -- おすすめ商品(4) null as c053 , -- 詳細-サブコメント(4) null as c054 , -- おすすめ商品(5) null as c055 , -- 詳細-サブコメント(5) null as c056 , -- おすすめ商品(6) null as c057 , -- 詳細-サブコメント(6) category_name as c058 -- 商品カテゴリ(※ 必須) category_name FROM public.articles;
4.CSVファイルとしてエクスポートする
COPY wrk_articles TO E'c:\\tmp\\import.txt' DELIMITERS ',';
なお、wrk_articlesテーブルで確認するSQLは下記通り。
SELECT c001, c005, c006, c007, c010, c013, c018, c019, c020, c021, c058 FROM wrk_articles where c005 = null or c006 = null or c007 = null or c010 = null or c013 = null or c018 = null or c019 = null or c020 = null or c021 = null or c058 = null
エクスポートデータしたデータを商品インポートよりインポートにて完了・・・と思いきや、なぜかうまくいかない・・・。疲れたから、今日はこれにて終了。