dinistavares / go-prestashop-api Goto Github PK
View Code? Open in Web Editor NEWPrestashop API Golang Wrapper
License: MIT License
Prestashop API Golang Wrapper
License: MIT License
I'm testing the api with default prestashop 8.1.3
params := &prestashop.ServiceListParams{
Display: &prestashop.ServiceListDisplay{
"id",
"name",
"price",
},
}
list, response, err := client.Product.List(params)
if err != nil {
slog.Error("prestashop", "err", err.Error())
return
}
slog.Info("prestashop", "response", response)
for _, v := range *list {
//slog.Info("prestashop", "product", v)
slog.Info("prestashop", "product", fmt.Sprintf("id: %d, name: %s, price: %s", v.ID, v.Name, v.Price))
}
Then I got these:
2024/01/12 22:33:48 INFO prestashop product="id: 1, name: , price: 23.900000"
2024/01/12 22:33:48 INFO prestashop product="id: 2, name: , price: 35.900000"
2024/01/12 22:33:48 INFO prestashop product="id: 16, name: , price: 12.900000"
Please help, thanks,
As the new struct LanguageData with Language array, the original key name should be changed back with the xml definition.
Product {
Names *LanguageData xml:"name,omitempty" json:"name,omitempty"
}
==> Product {
Name
}
and the Associations xml maybe error:
type ProductAssociations struct {
ProductRows *[]ProductRow xml:"product_rows>cart_row,omitempty" json:"cart_rows,omitempty"
}
Testing the find by email service, got these result:
2024/01/25 11:19:54 INFO prestashop "customer by email"="&{ID:0xc000014c08 IDDefaultGroup:3 IDLang:3 NewsletterDateAdd:2024-01-25 12:14:56 ..."
type Customer struct {
ID *int
...
}
Would the ID be changed to int better than *int?
Thanks
If possible, change the struct like this:
type ServiceListParams struct {
...
IDLang int
}
Then the client will return the list/detail data like:
lang = 1 & id = 1: p.Name => "Hummingbird printed t-shirt"
lang = 2 & id = 1: p.Name => "تيشيرت بطبعة الطائر الطنان"
Fill free if you have any better solution.
:)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.