最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python實(shí)現(xiàn)zencart產(chǎn)品數(shù)據(jù)導(dǎo)入到magento(python導(dǎo)入數(shù)據(jù))

 更新時(shí)間:2014年04月03日 10:36:14   作者:  
這篇文章主要介紹了python實(shí)現(xiàn)zencart產(chǎn)品數(shù)據(jù)導(dǎo)入到magento(python導(dǎo)入數(shù)據(jù)),需要的朋友可以參考下

python版本要求在3.3.x,需要mysql connector for python第三方庫支持

不適用所有的zencart導(dǎo)入到magento

復(fù)制代碼 代碼如下:

#encoding=utf-8
#@ author:凋零
#@ contact:342103944@qq.com
import mysql.connector
import sys
import time
import glob
import os
import re
import shutil
config={'host':'127.0.0.1','user':'root','password':'1','port':3306 ,'database':'zencart','charset':'utf8'} 
config1={'host':'127.0.0.1','user':'root','password':'1','port':3306 ,'database':'magento','charset':'utf8'}
zencart_image_dir="D:/wamp/www/public/images/"#此處改為自己實(shí)際路徑
magento_image_dir="D:/wamp/www/public1/media/catalog/product/"#此處改為自己實(shí)際路徑
#所有產(chǎn)品信息,列表類型
products=[]

#連接到zencart數(shù)據(jù)庫
try: 
    cnn=mysql.connector.connect(**config)

except mysql.connector.Error as e: 
    print('connect fails!{}'.format(e))


#連接到magento數(shù)據(jù)庫

try: 
    cnn_magento=mysql.connector.connect(**config1)

except mysql.connector.Error as e: 
    print('connect fails!{}'.format(e))


#連接到magento數(shù)據(jù)庫

try: 
    cnn_magento1=mysql.connector.connect(**config1)

except mysql.connector.Error as e: 
    print('connect fails!{}'.format(e))

#--------------獲取產(chǎn)品信息函數(shù)塊開始---------------#
#(獲取產(chǎn)品描述,返回字典)
def get_productdescription(product_id):
    global cnn
    product_id=str(product_id)
    description={}
    cursor_des=cnn.cursor()

    cursor_des.execute("select products_name,products_url from products_description where products_id="+product_id)
    temp_description=cursor_des.fetchone()
    description['name']=temp_description[0]
    description['url']=temp_description[1]

    return  description

#(獲取產(chǎn)品多圖,返回列表)
def get_productaddtionimage(product_image):

    base_dir="D:\\wamp\www\\public\\images\\"#此處改為自己實(shí)際路徑
    addtion_image=[]
    image_uri=(base_dir+product_image).replace('.jpg','')
    for i in range(16):
        if os.path.isfile(image_uri+'_'+str(i)+'.jpg'):
            addtion_image.append(product_image.replace('.jpg','')+'_'+str(i)+'.jpg')

           
    else:
        #print ("none")
        pass
    return addtion_image

#(獲取產(chǎn)品對應(yīng)目錄,返回列表)
def get_product_categories(product_id):

    product_id=str(product_id)

    categories=[]
    cursor=cnn.cursor()

    cursor.execute("select categories_id from products_to_categories where products_id="+product_id)

    for row in cursor.fetchall():

        for r in row:
            categories.append(r)

    return categories

#--------------獲取產(chǎn)品信息函數(shù)塊結(jié)束---------------#

#分類id對應(yīng)字典
categories_to={\
'2':'10','3':'13','4':'18','139':'37','176':'38','201':'70','202':'71','203':'69','204':'76','205':'77',\
'206':'66','207':'73','208':'72','209':'78','210':'79','211':'68','212':'74','213':'59','214':'60','215':'58','216':'62','217':'63','218':'64','219':'65','222':'54',\
'223':'53','224':'56','225':'80','230':'81','231':'48','232':'49','233':'50','234':'82','235':'83','236':'84','237':'45','238':'46',\
'239':'85','240':'51','241':'52','242':'86','245':'40','247':'44','248':'87','249':'43','250':'88','251':'89','252':'42',\
'260':'38','261':'38','271':'41',\
'279':'90','280':'39','281':'61','282':'91'\
}

#替換特殊字符函數(shù)
def cleanchar(str):

    str=str.replace('?','oe')
    str=str.replace('é','e')
    str=str.replace('è','e')
    str=str.replace('?','e')
    str=str.replace('?','i')
    str=str.replace('ê','e')
    str=str.replace('a','a')
    str=str.replace('à','a')
    str=str.replace('?','u')
    str=str.replace('ü','u')
    str=str.replace('?','ae')              
    str=str.replace('?','o')
    str=str.replace('?','o')
    str=str.replace('?','c')
    str=str.replace('?','i')
    str=str.replace('?','i')
    str=str.replace('?','i')
    str=str.replace("'","")
    str=str.lower()

    str=str.strip()

    return str


#函數(shù),檢查是否有相同的url,有則返回新url
def check_url(product_name,sku):
    cursor1=cnn_magento1.cursor()

    cursor1.execute("select value from catalog_product_entity_varchar where entity_type_id=10 and attribute_id=96 and value='"+str.strip(product_name)+"'")
    #result=cursor1.execute("select value_id from catalog_product_entity_varchar where entity_type_id=10 and attribute_id=96 and value='"+str.strip(test)+"'")
    #print ("select value_id from catalog_product_entity_varchar where entity_type_id=10 and attribute_id=96 and value='"+str.strip(product_name)+"'")
    row=cursor1.fetchall()

   
    if len(row)!=0:

        rstr = r"[\/\\\:\*\?\"\<\>\|]"
        url=str.strip(re.sub(rstr, "-", product_name))
        url=url.replace('?','oe')
        url=url.replace('é','e')
        url=url.replace('è','e')
        url=url.replace('?','e')
        url=url.replace('?','i')
        url=url.replace('ê','e')
        url=url.replace('a','a')
        url=url.replace('à','a')
        url=url.replace('?','u')
        url=url.replace('ü','u')
        url=url.replace('?','ae')              
        url=url.replace('?','o')
        url=url.replace('?','o')
        url=url.replace('?','c')
        url=url.replace('?','i')
        url=url.replace('?','i')
        url=url.replace('?','i')
        url=url.replace("'","")    
        url=url.lower()
        url=url.replace(' ','-')+'_'+sku.lower()

        return url
    else:

        rstr = r"[\/\\\:\*\?\"\<\>\|]"
        url=str.strip(re.sub(rstr, "-", product_name))
        url=url.replace('?','oe')
        url=url.replace('é','e')
        url=url.replace('è','e')
        url=url.replace('?','e')
        url=url.replace('?','i')
        url=url.replace('ê','e')
        url=url.replace('a','a')
        url=url.replace('à','a')
        url=url.replace('?','u')
        url=url.replace('ü','u')
        url=url.replace('?','ae')              
        url=url.replace('?','o')
        url=url.replace('?','o')
        url=url.replace('?','c')
        url=url.replace('?','i')
        url=url.replace('?','i')
        url=url.replace('?','i')
        url=url.replace("'","")
        url=url.lower()
        url=url.replace(' ','-')

        return url

   

#函數(shù),拷貝zencart產(chǎn)品圖片到magento目錄并根據(jù)產(chǎn)品名重命名
def copy_image_to_magento(image,sku,product_name,if_addition_image=False):
    if if_addition_image:
        #去除路徑,獲取圖片名稱
        image_name=os.path.basename(zencart_image_dir+image)
        #獲取圖片類型(后綴)
        extension = os.path.splitext(image_name)[1]
        #分拆圖片名稱
        image_all=image_name.split('_')

        #新的圖片名稱重命名后與產(chǎn)品名稱一樣(正則替換掉非法字符如/,\,|,*等)
        rstr = r"[\/\\\:\*\?\"\<\>\|]"
        new_image_name_noextension=str.strip(re.sub(rstr, "-", product_name))

       
        new_image_name_noextension=cleanchar(new_image_name_noextension)

      
        new_image_name=new_image_name_noextension+"_"+image_all[1]

       
        #判斷圖片是否存在
        if os.path.isfile(magento_image_dir+new_image_name):
            print ("\t\t\t\t存在圖片"+new_image_name)
            shutil.copy(zencart_image_dir+image,magento_image_dir+new_image_name_noextension+"_"+sku+"_"+image_all[1])
            return '/'+new_image_name_noextension+"_"+sku+"_"+image_all[1]
        else:
            print ("\t\t\t不存在圖片"+new_image_name+",執(zhí)行拷貝圖片并重命名")
            #不存在圖片則拷貝圖片到magento目錄并重命名
            shutil.copy(zencart_image_dir+image, magento_image_dir+new_image_name)
            return '/'+new_image_name

    else:
        #去除路徑,獲取圖片名稱
        image_name=os.path.basename(zencart_image_dir+image)
        #獲取圖片類型(后綴)
        extension = os.path.splitext(image_name)[1]
        #新的圖片名稱重命名后與產(chǎn)品名稱一樣(正則替換掉非法字符如/,\,|,*等)

        rstr = r"[\/\\\:\*\?\"\<\>\|]"
        new_image_name_noextension=str.strip(re.sub(rstr, "-", product_name))
        new_image_name_noextension=cleanchar(new_image_name_noextension)

        new_image_name=cleanchar(str.strip(re.sub(rstr, "-", product_name)))+extension

   
        #先判斷圖片是否存在
        if os.path.isfile(magento_image_dir+new_image_name):
            print ("\t\t\t\t存在圖片"+magento_image_dir+new_image_name+"\n")
            #存在圖片,則加sku
            shutil.copy(zencart_image_dir+image, magento_image_dir+new_image_name_noextension+"_"+sku+extension)
            return '/'+new_image_name_noextension+"_"+sku+extension

        else:
            print ("\t\t\t\t不存在圖片"+magento_image_dir+new_image_name+",執(zhí)行拷貝圖片并重命名\n")
            #不存在圖片則拷貝圖片到magento目錄并重命名
            shutil.copy(zencart_image_dir+image, magento_image_dir+new_image_name)
            return '/'+new_image_name

  

 


product_sql='select * from products'
cursor=cnn.cursor()
cursor1=cnn.cursor()
cursor.execute(product_sql)
cursor.fetchall()

#返回產(chǎn)品總個(gè)數(shù)
numrows = cursor.rowcount

 

 

i=0
cursor1.execute(product_sql)
print ("作者:凋零(qq:342103944)")
print ("開始獲取zencart數(shù)據(jù)庫產(chǎn)品信息..........")
time.sleep(3)
for row in cursor1.fetchall():
    #臨時(shí)產(chǎn)品列表
    temp_product=[]

    #存放產(chǎn)品信息,字典類型
    product_info={}

    for r in row:
        #循環(huán)存放產(chǎn)品信息到產(chǎn)品列表
        temp_product.append(r)

    product_info['product_id']=temp_product[0]
    product_info['sku']=temp_product[3]
    product_info['product_image']=temp_product[4]
    product_info['price']=temp_product[5]
    product_info['silhouette']=temp_product[6].replace('\n','')
    product_info['neckline']=temp_product[7].replace('\n','')
    product_info['waist']=temp_product[8].replace('\n','')
    product_info['hemline']=temp_product[9].replace('\n','')
    product_info['sleeve_length']=temp_product[10].replace('\n','')
    product_info['sleeve_type']=temp_product[11].replace('\n','')
    product_info['fabric']=temp_product[12].replace('\n','')
    product_info['embellishment']=temp_product[13].replace('\n','')
    product_info['belt_fabric']=temp_product[14].replace('\n','')
    product_info['back_detail']=temp_product[15].replace('\n','')
    product_info['fully_lined']=temp_product[16].replace('\n','')
    product_info['built_in_bra']=temp_product[17].replace('\n','')
    product_info['body_shape']=temp_product[18].replace('\n','')
    product_info['season']=temp_product[19].replace('\n','')
    product_info['color']=temp_product[20].replace('\n','')
    product_info['special_price']=temp_product[42]
    product_info['master_categories_id']=temp_product[43]
    product_info['product_name']=get_productdescription(product_info['product_id'])['name']
    product_info['addtion_image']=get_productaddtionimage(product_info['product_image'])
    product_info['product_categories']=get_product_categories(product_info['product_id'])

   
    products.append(product_info)

    i=i+1

cursor1.close
print ("獲取數(shù)據(jù)完畢總共數(shù)據(jù)為:"+str(i)+"條")
time.sleep(1)
print ("開始轉(zhuǎn)存數(shù)據(jù)到magento庫.......")
time.sleep(1)
#----------------------------------------#
#------                              ----#
#------   開始存儲數(shù)據(jù)到magento庫      ----#
#------                              ----#
#----------------------------------------#


cursor=cnn_magento.cursor()
cursor.execute("set foreign_key_checks = 0")
not_import_categores_id=[]
p=0
for j in range(len(products)):

    product_id=products[j]['product_id']

    product_sku=products[j]['sku']
    product_baseimage=products[j]['product_image']
    product_price=products[j]['price']
    product_silhouette=products[j]['silhouette']
    product_neckline=products[j]['neckline']
    product_waist=products[j]['waist']
    product_hemline=products[j]['hemline']
    product_sleeve_length=products[j]['sleeve_length']
    product_sleeve_type=products[j]['sleeve_type']
    product_fabric=products[j]['fabric']
    product_embellishment=products[j]['embellishment']
    product_belt_fabric=products[j]['belt_fabric']
    product_back_detail=products[j]['back_detail']
    product_fully_lined=products[j]['fully_lined']
    product_built_in_bra=products[j]['built_in_bra']
    product_body_shape=products[j]['body_shape']
    product_season=products[j]['season']
    product_color=products[j]['color']
    product_special_price=products[j]['special_price']
    product_master_categories_id=products[j]['master_categories_id']
    product_name=products[j]['product_name']
    product_addtion_image=products[j]['addtion_image']
    product_to_categories=products[j]['product_categories']



    #判斷兩個(gè)數(shù)據(jù)庫之間分類是否對應(yīng),然后插入數(shù)據(jù)到magneto庫,沒有則不執(zhí)行
    if str(product_master_categories_id) in categories_to.keys():
        p=p+1
        print ("---第【"+str(p)+"】條:"+product_sku)

   
        #開始轉(zhuǎn)存數(shù)據(jù)到catalog_product_entity表
        cursor.execute("insert into catalog_product_entity set entity_type_id=10,attribute_set_id=9,type_id='simple',sku='"+product_sku+"',created_at='2013-05-27 03:18:42',updated_at='2013-05-29 07:59:35',has_options=1,required_options=1")
      

        #獲取實(shí)體(產(chǎn)品)id
        catalog_entity_id=cursor.lastrowid

        #插入數(shù)據(jù)到產(chǎn)品分類對應(yīng)表
        for categories_id in product_to_categories:

            if str(categories_id) in categories_to.keys():
                 cursor.execute("insert into catalog_category_product set category_id="+categories_to[str(categories_id)]+",product_id="+str(catalog_entity_id)+",position=1")
                 for i in range(1,4):

                     cursor.execute("insert into catalog_category_product_index set category_id="+str(categories_id)+",product_id="+str(catalog_entity_id)+",position=1,is_parent=1,store_id="+str(i)+",visibility=4")
                    

        #插入產(chǎn)品相關(guān)值到實(shí)體時(shí)間值表
        cursor.execute("insert into catalog_product_entity_datetime set entity_type_id=10,attribute_id=704,store_id=0,entity_id="+str(catalog_entity_id)+",value='2013-05-19 00:00:00'")
        cursor.execute("insert into catalog_product_entity_datetime set entity_type_id=10,attribute_id=705,store_id=0,entity_id="+str(catalog_entity_id)+",value='2013-05-25 00:00:00'")
        cursor.execute("insert into catalog_product_entity_datetime set entity_type_id=10,attribute_id=572,store_id=0,entity_id="+str(catalog_entity_id))
        cursor.execute("insert into catalog_product_entity_datetime set entity_type_id=10,attribute_id=573,store_id=0,entity_id="+str(catalog_entity_id))

        #插入促銷價(jià)格,如果沒促銷價(jià)格則不執(zhí)行
        if product_special_price!='':

            cursor.execute("insert into catalog_product_entity_decimal set entity_type_id=10,attribute_id=567,store_id=0,entity_id="+str(catalog_entity_id)+",value="+str(product_special_price))

        #插入產(chǎn)品重量,產(chǎn)品價(jià)格
        cursor.execute("insert into catalog_product_entity_decimal set entity_type_id=10,attribute_id=101,store_id=0,entity_id="+str(catalog_entity_id)+",value=2")
        cursor.execute("insert into catalog_product_entity_decimal set entity_type_id=10,attribute_id=99,store_id=0,entity_id="+str(catalog_entity_id)+",value="+str(product_price))
        cursor.execute("insert into catalog_product_entity_decimal set entity_type_id=10,attribute_id=943,store_id=0,entity_id="+str(catalog_entity_id))

        #插入產(chǎn)品相關(guān)值到實(shí)體整型表(產(chǎn)品狀態(tài),關(guān)稅,前臺可見,制造商,enable_googlecheckout)

        cursor.execute("insert into catalog_product_entity_int set entity_type_id=10,attribute_id=273,store_id=0,entity_id="+str(catalog_entity_id)+",value=1")
        cursor.execute("insert into catalog_product_entity_int set entity_type_id=10,attribute_id=274,store_id=0,entity_id="+str(catalog_entity_id)+",value=1")
        cursor.execute("insert into catalog_product_entity_int set entity_type_id=10,attribute_id=526,store_id=0,entity_id="+str(catalog_entity_id)+",value=4")
        cursor.execute("insert into catalog_product_entity_int set entity_type_id=10,attribute_id=102,store_id=0,entity_id="+str(catalog_entity_id))
        cursor.execute("insert into catalog_product_entity_int set entity_type_id=10,attribute_id=903,store_id=0,entity_id="+str(catalog_entity_id)+",value=1")
        cursor.execute("insert into catalog_product_entity_int set entity_type_id=10,attribute_id=935,store_id=0,entity_id="+str(catalog_entity_id)+",value=0")

        #####拷貝產(chǎn)品圖片到magento目錄并插入到數(shù)據(jù)庫#######

        #拷貝并插入主圖
        base_image_in_magento=copy_image_to_magento(product_baseimage,product_sku,product_name,False)
        cursor.execute("insert into catalog_product_entity_media_gallery set attribute_id=703,entity_id="+str(catalog_entity_id)+",value='"+base_image_in_magento+"'")
        gallery_id=cursor.lastrowid
        cursor.execute("insert into catalog_product_entity_media_gallery_value set value_id="+str(gallery_id)+",store_id=0,position=1,disabled=0")
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=493,store_id=0,entity_id="+str(catalog_entity_id)+",value='"+base_image_in_magento+"'")
        #small_image
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=109,store_id=0,entity_id="+str(catalog_entity_id)+",value='"+base_image_in_magento+"'")
        #image
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=106,store_id=0,entity_id="+str(catalog_entity_id)+",value='"+base_image_in_magento+"'")

        #拷貝并插入附加圖
        if len(product_addtion_image)!=0:
            iii=2
            for each_image in product_addtion_image:
                addition_image_in_magento=copy_image_to_magento(each_image,product_sku,product_name,True)
                cursor.execute("insert into catalog_product_entity_media_gallery set attribute_id=703,entity_id="+str(catalog_entity_id)+",value='"+addition_image_in_magento+"'")
                addition_id=cursor.lastrowid
                cursor.execute("insert into catalog_product_entity_media_gallery_value set value_id="+str(addition_id)+",store_id=0,position="+str(iii)+",disabled=0")
                iii=iii+1

        #插入產(chǎn)品相關(guān)值到實(shí)體文本表(產(chǎn)品描述,段描述等)
        cursor.execute("insert into catalog_product_entity_text set entity_type_id=10,attribute_id=506,store_id=0,entity_id="+str(catalog_entity_id)+",value='short_description&&nbsp&&nbsp'")
        cursor.execute("insert into catalog_product_entity_text set entity_type_id=10,attribute_id=531,store_id=0,entity_id="+str(catalog_entity_id))
        cursor.execute("insert into catalog_product_entity_text set entity_type_id=10,attribute_id=104,store_id=0,entity_id="+str(catalog_entity_id))
        cursor.execute("insert into catalog_product_entity_text set entity_type_id=10,attribute_id=97,store_id=0,entity_id="+str(catalog_entity_id)+",value='description&&nbsp&&nbsp'")


        #插入產(chǎn)品到catalog_product_entity_varchar(產(chǎn)品名稱,url等)
        #插入name
        product_name=product_name.replace("'","")
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=96,store_id=0,entity_id="+str(catalog_entity_id)+",value='"+str.strip(product_name)+"'")
        #插入url_key
        url=check_url(product_name,product_sku)
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=481,store_id=0,entity_id="+str(catalog_entity_id)+",value='"+str.strip(url)+"'")
        #manufacture
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=940,store_id=0,entity_id="+str(catalog_entity_id))
        #msrp_enabled
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=941,store_id=0,entity_id="+str(catalog_entity_id)+",value=2")
        #msrp_display_actual_price_type
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=942,store_id=0,entity_id="+str(catalog_entity_id)+",value=4")
        #meta_title
        #cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=103,store_id=0,entity_id="+str(catalog_entity_id)+",value=4")
        #meta_description
        #cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=105,store_id=0,entity_id="+str(catalog_entity_id)+",value=4")

        #thumbnail
        #print ("insert into `catalog_product_entity_varchar` set `entity_type_id`=10,`attribute_id`=493,`store_id`=0,`entity_id`="+str(catalog_entity_id)+",`value`='no_selection'")
        #input()
        #cursor.execute("insert into `catalog_product_entity_varchar` set `entity_type_id`=10,`attribute_id`=493,`store_id`=0,`entity_id`="+str(catalog_entity_id)+",`value`='no_selection'")

        #custom_design
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=571,store_id=0,entity_id="+str(catalog_entity_id))
        #options_container
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=836,store_id=0,entity_id="+str(catalog_entity_id)+",value='container2'")
        #page_layout
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=931,store_id=0,entity_id="+str(catalog_entity_id))
        #gift_message_available
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=562,store_id=0,entity_id="+str(catalog_entity_id)+",value=1")

        #thumbnail_label
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=881,store_id=0,entity_id="+str(catalog_entity_id))
        #small_image_label
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=880,store_id=0,entity_id="+str(catalog_entity_id))

        #image_label
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=879,store_id=0,entity_id="+str(catalog_entity_id))

        #url_path
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=570,store_id=0,entity_id="+str(catalog_entity_id)+",value='"+str.strip(url)+"'")
        cursor.execute("insert into catalog_product_entity_varchar set entity_type_id=10,attribute_id=570,store_id=1,entity_id="+str(catalog_entity_id)+",value='"+str.strip(url)+"'")

        #插入catalog_product_flat(1,2,3)表
        for aa in range(1,4):
            cursor.execute("insert into catalog_product_flat_"+str(aa)+" set entity_id="+str(catalog_entity_id)+",attribute_set_id=9,type_id='simple',created_at='2013-05-31 06:43:21'\
            ,description='test test ,&&nbsp',enable_googlecheckout=1,has_options=1,image='"+base_image_in_magento+"',is_recurring=0,msrp_display_actual_price_type=4\
            ,msrp_enabled=2,name='"+product_name+"',price="+str(product_price)+",required_options=1,short_description='short description &&nbsp',sku='"+product_sku+"'\
            ,small_image='"+base_image_in_magento+"',special_from_date='2013-05-19 00:00:00',special_price="+str(product_special_price)+",special_to_date='2014-06-27 00:00:00'\
            ,tax_class_id=1,thumbnail='no_selection',updated_at='2013-05-31 10:38:25',url_key='"+url+"',url_path='"+url+"',visibility=4,weight=2")
        for aa in range(1,4):
            cursor.execute("insert into catalog_product_index_eav set entity_id="+str(catalog_entity_id)+",attribute_id=903,store_id="+str(aa)+",value=1")
            cursor.execute("insert into catalog_product_index_eav set entity_id="+str(catalog_entity_id)+",attribute_id=971,store_id="+str(aa)+",value=128")

        #catalog_product_index_eav_idx
        for aa in range(1,4):
            cursor.execute("insert into catalog_product_index_eav_idx set entity_id="+str(catalog_entity_id)+",attribute_id=903,store_id="+str(aa)+",value=1")

        #catalog_product_index_price
        for aa in range(5):
            cursor.execute("insert into catalog_product_index_price set entity_id="+str(catalog_entity_id)+",customer_group_id="+str(aa)+",website_id=1,tax_class_id=1,price="+str(product_price)+"\
            ,final_price="+str(product_special_price)+",min_price="+str(product_special_price)+",max_price="+str(product_special_price))
        #catalog_product_index_price_idx
        for aa in range(5):
            cursor.execute("insert into catalog_product_index_price_idx set entity_id="+str(catalog_entity_id)+",customer_group_id="+str(aa)+",website_id=1,tax_class_id=1,price="+str(product_price)+"\
            ,final_price="+str(product_special_price)+",min_price="+str(product_special_price)+",max_price="+str(product_special_price))   
        #catalog_product_website
        cursor.execute("insert into catalog_product_website set product_id="+str(catalog_entity_id)+",website_id=1")

        #cataloginventory_stock_item
        cursor.execute("insert into cataloginventory_stock_item set product_id="+str(catalog_entity_id)+",stock_id=1,qty=1000,min_qty=0,use_config_min_qty=1,is_qty_decimal=0,\
        backorders=0,use_config_backorders=1,min_sale_qty=1,use_config_min_sale_qty=1,max_sale_qty=0,use_config_max_sale_qty=1,is_in_stock=1,use_config_notify_stock_qty=1,\
        manage_stock=0,use_config_manage_stock=1,stock_status_changed_auto=0,use_config_qty_increments=1,qty_increments=0,use_config_enable_qty_inc=1,enable_qty_increments=0,\
        is_decimal_divided=0")
        #cataloginventory_stock_status
        cursor.execute("insert into cataloginventory_stock_status set product_id="+str(catalog_entity_id)+",website_id=1,stock_id=1,qty=1000,stock_status=1")
        #cataloginventory_stock_status_idx
        cursor.execute("insert into cataloginventory_stock_status_idx set product_id="+str(catalog_entity_id)+",website_id=1,stock_id=1,qty=1000,stock_status=1")
        cnn_magento.commit()
    else:
        print ("\t\t\tid["+str(product_master_categories_id)+"]在magneto庫中沒有與之對應(yīng)的id,跳過此分類")
        not_import_categores_id.append(str(product_master_categories_id))

cursor.execute("set foreign_key_checks = 1")
cursor.close
print ("導(dǎo)入完成")
print ("一共有"+str(len(not_import_categores_id))+"沒導(dǎo)入")

  • python實(shí)現(xiàn)將視頻按幀讀取到自定義目錄

    python實(shí)現(xiàn)將視頻按幀讀取到自定義目錄

    今天小編就為大家分享一篇python實(shí)現(xiàn)將視頻按幀讀取到自定義目錄,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • python函數(shù)的兩種嵌套方法使用

    python函數(shù)的兩種嵌套方法使用

    本文主要介紹了python函數(shù)的兩種嵌套方法使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04
  • Python編程新標(biāo)準(zhǔn)學(xué)會十項(xiàng)好習(xí)慣提升編碼質(zhì)量

    Python編程新標(biāo)準(zhǔn)學(xué)會十項(xiàng)好習(xí)慣提升編碼質(zhì)量

    這篇文章主要為大家介紹了Python編程新標(biāo)準(zhǔn)學(xué)會十項(xiàng)好習(xí)慣提升編碼質(zhì)量,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2024-01-01
  • 在 Jupyter 中重新導(dǎo)入特定的 Python 文件(場景分析)

    在 Jupyter 中重新導(dǎo)入特定的 Python 文件(場景分析)

    Jupyter 是數(shù)據(jù)分析領(lǐng)域非常有名的開發(fā)環(huán)境,使用 Jupyter 寫數(shù)據(jù)分析相關(guān)的代碼會大大節(jié)約開發(fā)時(shí)間。這篇文章主要介紹了在 Jupyter 中如何重新導(dǎo)入特定的 Python 文件,需要的朋友可以參考下
    2019-10-10
  • Python批處理更改文件名os.rename的方法

    Python批處理更改文件名os.rename的方法

    今天小編就為大家分享一篇Python批處理更改文件名os.rename的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-10-10
  • Python格式化輸出詳情

    Python格式化輸出詳情

    這篇文章介紹了Python格式化輸出,主要講解Python格式化輸出的三種方式:%格式化、format格式化、f-String格式化,需要的朋友可以參考下面文章的具體內(nèi)容
    2021-09-09
  • 在PyCharm中安裝PaddlePaddle的方法

    在PyCharm中安裝PaddlePaddle的方法

    這篇文章主要介紹了在PyCharm中安裝PaddlePaddle的方法,本文給大家介紹的非常想詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-02-02
  • Python實(shí)現(xiàn)數(shù)值交換的四種方式

    Python實(shí)現(xiàn)數(shù)值交換的四種方式

    本文介紹了Python中四種實(shí)現(xiàn)數(shù)值交換的方法,包括使用臨時(shí)變量、元組解包、列表和異或運(yùn)算,具有一定的參考價(jià)值,感興趣的可以了解一下
    2025-01-01
  • Python多進(jìn)程Process和管道Pipe的使用方式

    Python多進(jìn)程Process和管道Pipe的使用方式

    這篇文章主要介紹了Python多進(jìn)程Process和管道Pipe的使用方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • 最新評論

    信丰县| 栖霞市| 香格里拉县| 太康县| 奉化市| 兰考县| 岳池县| 新绛县| 肥西县| 南雄市| 乌什县| 开鲁县| 博客| 同仁县| 山阳县| 定边县| 新化县| 乐昌市| 烟台市| 白山市| 石家庄市| 新巴尔虎左旗| 福清市| 鸡泽县| 奉节县| 响水县| 离岛区| 宁陵县| 峡江县| 碌曲县| 招远市| 且末县| 鹤山市| 新河县| 汝州市| 刚察县| 青冈县| 吴堡县| 乌兰察布市| 宁陕县| 南皮县|