Jump to content

Api & VBA


motabik
 Share

Recommended Posts

Hi
I develop import data from excel to prestashop with API.
I have little problem with images management.
What I create to send and import image for products.
Communications is ready and I haven't any problem
Here is my code.

pathImage = "image=c:\Users\Downloads\blade.jpg"
Dim TargetUrl As String
TargetUrl = "http://MyPresta/api/images/products/2"
Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1")
HTTPReq.Option(4) = 13056 '
HTTPReq.Open "get", TargetUrl, False
HTTPReq.SetCredentials "user", "password", 0
HTTPReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

HTTPReq.send (pathImage)
MsgBox (HTTPReq.responseText)

 

Share this post


Link to post
Share on other sites

  • 1 year later...

Yes, I wrote program to add, update all products, generate photos,
and updated stock, price, status, etc.
But I do this not API, becauce it not working good.

I installed odbc for mysql and created connection with ADODB
then I can update any table in database.

here you have simple code.


Private Const PrestaAccessMySql As String = "Driver={MySQL ODBC 3.51 Driver}; Server=serverDomain; Database=databaseName; Uid=databaseLogin; Pwd=databasePassword;"

If you connect with other driver you must change Driver=
Driver={MySQL ODBC 5.3 ANSI Driver}
or other

Function doQuery(ByRef txQuery As String) As Integer
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
On Error GoTo transError
Set conn = New ADODB.Connection
conn.Open PrestaAccessMySql
Set rst = New ADODB.Recordset
rst.Open txQuery, conn
doQuery = 1
conn.Close

Exit Function
transError:
doQuery = 0
   conn.RollBack
   rst.Close
      conn.Close
   MsgBox Err.description
End Function

good luck



 

Share this post


Link to post
Share on other sites

  • 4 months later...

Hi,

 

I couldn't figure it out...

Could you please provide me more detailed instructions?

I only need a simple example, then I can develop it.

 

For example I need to change the quantity of the product with ID 111111 from 1 to 0 and also de-activate the same product.

 

Could you please send me an .xlsm file as example?

 

Thank you so much!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More