FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour EXPORTAR DATOS FW A PRESTASHOP [SOLUCIONADO PROBLEMA IMAGEN]
Posts: 199
Joined: Wed Jan 02, 2019 08:36 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Tue Dec 27, 2022 06:40 PM

Buenas tardes Navarro

Me uno a la petición

deumare arroba gmail punto com

gracias

Jesús Marín
deumare@gmail.com
Posts: 476
Joined: Sat Feb 03, 2007 06:36 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Wed Dec 28, 2022 01:01 PM

Cristobal, yo tambien me uno a la petición, me puedes compartir la clase por favor.

sincuir.romero arroba gmail.com

Gracias

Carlos

Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Wed Dec 28, 2022 10:04 PM
Cristobal, buenas tardes,

Una solicitud más, te agradeceré si me envías tu clase: cgallegoaecu@gmail.com

Gracias y feliz navidad

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 199
Joined: Wed Jan 02, 2019 08:36 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Thu Dec 29, 2022 04:39 AM
Buenos dias
Sigo con las pruebas

Me he encontrado este pequeño problema.
Al generar el fichero CSV con la instrución :
Code (fw): Select all Collapse
COPY TO cNuevoFichero DELIMITED WITH ( { "",";" } )
el último caracter del fichero tiene un valor ASCII 26

ASCII HEX SIMBOLO DESCRIPCION
-----------------------------------------------------------------------
26 1A SUB SUBSTITUIR - REEEMPLAZAR

Esto provoca que al importarse en PRESTASHOP genera un registro falso, sin datos.

Alguien sabe como evitarlo o como eliminarlo ?

Lo he intentado con FWRITE() sin exito.

Gracias
Jesús Marín
deumare@gmail.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Thu Dec 29, 2022 08:58 AM

Prueba a leer el fichero usando hb_memoRead() y lo vuelves a salvar con hb_memoWrit() quitando el ultimo caracter usando SubStr()

hb_memoWrit( "nombreFichero", SubStr( hb_memoRead( "nombreFichero" ), 1, Len( hb_memoRead( "nombreFichero" ) ) - 1 )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 199
Joined: Wed Jan 02, 2019 08:36 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Thu Dec 29, 2022 10:45 AM

Gracias Antonio por contestar.

Antes de leer tu respuesta he probado lo siguiente y parece que SI funciona.

Antes del codigo de control 26, estaba un salto de carro CHR(13)+CHR(10), así que se me ha ocurrido escribir tres espacios en blanco, donde estaba la cadena CHR(13)+CHR(10)+CHR(26).

En principio funciona.

Gracias de nuevo.

Jesús Marín

Jesús Marín
deumare@gmail.com
Posts: 199
Joined: Wed Jan 02, 2019 08:36 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Mon Jan 02, 2023 01:29 PM

Buenos dias a todos y Feliz Año

La verdad es que me estoy volviendo loco con la importación de las imagenes.

Al final, creo el fichero CSV desde FW pero por algún motivo la imagen no se carga ni se crean las miniaturas.

Algo extraño.

Tendre que acabar comprando un módulo para hacer importaciones.

Saludos a todos

Jesús Marín
deumare@gmail.com
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Mon Jan 02, 2023 03:40 PM

Como cargas las imágenes?

Enviado desde mi motorola edge 20 mediante Tapatalk

--------

¿ Y porque no ?

¿ And why not ?
Posts: 199
Joined: Wed Jan 02, 2019 08:36 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Tue Jan 03, 2023 03:46 AM
Buenos dias
1) He creado un directorio en el raiz (tambien he probado en /public_html/img)
2) Copio en ese directorio la(s) imagenes en formato .jpg
3) En el fichero que exporto desde FW, pongo la url de 1 sola imagen. P.ej.: https://deumare.com/lalimagenes/318.jpg
4) Hago la importación desde el back office de PS

No da error de ningun tipo (no existe el fichero o no válido), pero no carga ninguna imagen, ni genera las miniaturas.

Saludos
Jesús Marín
deumare@gmail.com
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Tue Jan 03, 2023 07:00 AM
No sé si de la forma que lo estás haciendo es válido.
Prestashop ya tiene un método para subir las imágenes, si lo haces así, te genera las miniaturas y todo lo necesario para el correcto funcionamiento:
https://devdocs.prestashop-project.org/8/webservice/tutorials/advanced-use/image-management/
Yo con el Curl que incluye HB no lo pude conseguir ya que me faltaba la clase CurlFile(). Supongo que podría crearla investigando los datos que necesita, pero lo tengo con una llamada a la línea de comandos y el curl.exe
Code (fw): Select all Collapse
curl.exe -v -u WSKEY:WSKEY -F "image=@c:\nombreimagen.jpg -k http://url/images/products/123
donde 123 es el ID del producto y WSKEY es la llave del WS de prestashop

espero te sirva de ayuda.

Salud!
--------

¿ Y porque no ?

¿ And why not ?
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Sat Jan 07, 2023 11:16 AM
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 )))
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 199
Joined: Wed Jan 02, 2019 08:36 AM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Sat Jan 07, 2023 05:07 PM
Marc Venken 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 )))
Good afternoon Mark
Yes, you are absolutely right.
I have already managed to import many things, but I still have problems with the images. I'm looking (they're looking at me) at a couple of settings, in case it's a configuration issue.
But, I am very afraid, that I will end up buying a module.
Thank you for your comments and your recommendation.

Jesús Marín
(Valencia) Spain
Jesús Marín
deumare@gmail.com
Posts: 115
Joined: Fri Oct 14, 2005 07:10 PM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Fri Jan 13, 2023 03:43 PM
Respecto a la sincronización de la Base de Datos, aqui un ejemplo de como lo hago :
En mi caso ingreso manualmente los productos en Prestashop pero, la actualización de precio y stock lo hago en este proceso:

Este código es lo primero que salió, sé que puede mejorar :)
Code (fw): Select all Collapse
   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
Saludos,

Gonzalo

Puerto Montt - CHILE

FWH 22.12 - Harbour 3.2.0dev (r2008190002) - Borland/Embarcadero C++ 7.0(32-bit)
Posts: 492
Joined: Wed Nov 16, 2005 12:03 PM
Re: EXPORTAR DATOS DESDE FW A PRESTASHOP
Posted: Sat Jan 14, 2023 10:08 PM

Saludos

Estoy interesado en implementar mercado Libre, si algun colega lo tiene implementado podemos adquirir el código fuente.

Posts: 199
Joined: Wed Jan 02, 2019 08:36 AM
Re: EXPORTAR DATOS FW A PRESTASHOP [SOLUCIONADO PROBLEMA IMAGEN]
Posted: Mon Jan 16, 2023 11:16 AM

Buenos dias a todos

Solucionado el problema con las imagenes. (desactivar URLs amigables)

Sigo con las pruebas de importación, pero por si sirve de ayuda a alguien en el futuro, puedo ayudaros.

Un saludo

Jesús Marín

Valencia (España)

Jesús Marín
deumare@gmail.com