COPY TO cNuevoFichero DELIMITED WITH ( { "",";" } )
JESUS MARIN wrote:Tendre que acabar comprando un módulo para hacer importaciones.
Saludos a todos
Marc Venken wrote:JESUS MARIN wrote:Tendre que acabar comprando un módulo para hacer importaciones.
Saludos a todos
I think you better do that.... Not always interesting reinventing the wheel ))))
Presta evolves and the import modules also. With a module you always will have a good working program and you only have to deliver the data as CSV or XLS. That never changes... Presta Does.
I used several mudules and be far the best in performance and use was :
Product Catalog (CSV, Excel) Import : Will be around 140 euro. In Belgium a IT's = 70 euro a hour )))
oCnW = maria_Connect( cSvr, cMdb, cUsu, cPsw )
if ! Empty( "ps2v_product" )
oRs := oCnW:RowSet( "select * from `"ps2v_product"`" )
if oRs == nil
? "Falló la apertura de ps2v_product"
else
LeeProduc( oRs, oCn, oCnW, aVars )
endif
endif
STATIC PROCEDURE LeeProduc( oRs, oCn, oCnW, aVars )
*----------------------------------------------------
oRs:Gotop()
DO WHILE .NOT. oRs:Eof()
cCodigo := RTRIM(oRs:Reference)
IF .NOT. Empty(cCodigo)
cSeek := "Codigo = '" + cCodigo + "'"
TRY
oPRODUC:Find( cSeek, 0, 1, 1 )
CATCH oError
MsgInfo( oError:Description )
FW_ShowAdoError( oCn )
END
IF .NOT. oPRODUC:Eof()
*------> Registro en mi BD SQL que este producto está en PS y guardo el índice que creó PS
oPRODUC:Fields("EnWeb"):Value := 1
oPRODUC:Fields("CodWeb"):Value := oRs:Id_Product
oPRODUC:Update()
*-----> Registro Stock del producto en Tabla "ps2v_stock_available" de PrestaShop
oSTOCKAV := oCnW:RowSet( "SELECT * FROM ps2v_stock_available WHERE Id_Product = " + STR(oRs:Id_Product) )
IF .NOT. oSTOCKAV:Eof()
oSTOCKAV:Fields("physical_quantity"):value := oPRODUC:Fields("StkReal"):Value
oSTOCKAV:Fields("quantity"):value := oPRODUC:Fields("StkReal"):Value
oSTOCKAV:Update()
ELSE
MsgAlert("No encontré STOCKAV : " )
ENDIF
*-----> Registro el Precio del producto en Tabla "ps2v_product" de PrestaShop
oPRODWEB := oCnW:RowSet( "SELECT * FROM ps2v_product WHERE Id_Product = " + STR(oRs:Id_Product) )
IF .NOT. oPRODWEB:Eof()
oPRODWEB:Fields("price"):value := oPRODUC:Fields("PrVenta"):Value
oPRODWEB:Update()
ELSE
MsgAlert("No encontré PRODWEB : " )
ENDIF
*-----> Registro el Precio del producto en Tabla "ps2v_layered_price_index" de PrestaShop
oLAYPRICE := oCnW:RowSet( "SELECT * FROM ps2v_layered_price_index WHERE Id_Product = " + STR(oRs:Id_Product) )
IF .NOT. oLAYPRICE:Eof()
oLAYPRICE:Fields("price_min"):value := oPRODUC:Fields("PrVenta"):Value * 1.19
oLAYPRICE:Fields("price_max"):value := oPRODUC:Fields("PrVenta"):Value * 1.19
oLAYPRICE:Update()
ELSE
MsgAlert("No encontré LAYPRICE : " )
ENDIF
*-----> Registro el Precio del producto en Tabla "ps2v_product_shop" de PrestaShop
oPRDSHOP := oCnW:RowSet( "SELECT * FROM ps2v_product_shop WHERE Id_Product = " + STR(oRs:Id_Product) )
IF .NOT. oPRDSHOP:Eof()
oPRDSHOP:Fields("price"):value := oPRODUC:Fields("PrVenta"):Value
oPRDSHOP:Update()
ELSE
MsgAlert("No encontré PRDSHOP : " )
ENDIF
ENDIF
else
MsgAlert("Código en blanco")
endif
oRs:MoveNext()
ENDDO
RETURN
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 42 guests