New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
product variants? #3
Comments
Hey, yes, it does. You can do something like: combination = Prestashop::Mapper::Combination.new(
id_lang: 1, id_product: 123, reference: 'unique-identifier')
combination.id_product_options = Prestashop::Mapper::ProductOption
.create_from_hash([{name: 'Color', value: 'Red'}, {name: 'Size', value: 'M'], 1)
combination.id_images = Prestashop::Mapper::Image.new(
resource: 'products', id_resource: 123, source: ['http://lorempixel.com/400/200/cats/']).upload
combination.create |
Hm. I cannot connect
I am getting
I checked the endpoint
and the key is copy & pasted. The shop is version 1.6.1.2. Any idea? |
You can track communication between your app and store to see what's happening.
|
Thanks, that was helpful. Seems it's getting a 503. Odd. Maybe I need to try with
|
All good. The "save" to turn on the webservice got lost :) |
Good, glad to hear that :) |
almost there... when I run this
I run into
form the code I could not yet figure out whether I need to provide the name - but it seems like that doesn't solve it anyway. Any suggestions what's still missing? |
Yes, you have to have a name, when you want to create product, I forgot.. https://github.com/werein/prestashop/blob/master/lib/prestashop/mapper/models/product.rb#L70 This should solve the problem.. Prestashop::Mapper::Product.new(id_lang: id_lang, id_supplier: id_supplier, reference: 'apple-macbook', name: 'MacBook') I'll update readme later on. |
Yes, I tried that but that gives:
Seems there is some |
You're right, it's extracted from rails. Yes, that would be great |
Slooowly getting there. For now I've just added
Not sure I get the usage of But most importantly - where is the |
Almost there. Now came across
|
so apparently |
To debug further I've set Do you see a reason why this could create an error?
|
Even a more complex example works in dev mode - only though. This is just odd. There are still a few open questions:
|
Plain is sanitising string..
I'll go through open questions.
You can set price of products option like that: @combination = Prestashop::Mapper::Combination.new(
id_lang: 'id-lang', id_product: 'product-id', reference: 'combination-reference')
if @combination.find?
@combination.price = 123
@combination.create
end And I've no clue why it works only in DEV mode, do you have your own hosting or you use cloud solutions? |
Seems like the reference isn't really needed. If I don't know the id I would search for the name. Still not sure I get the idea behind this - but anway.
Great! The naming is a little of (as it's a price change) but that's fine :) The supplier article number is the number you use for ordering the article by the supplier. Setting this makes it easier to map your article number to the supplier article number. I've attached a screenshot. |
Another head scratcher is the tax. On the product I found https://github.com/werein/prestashop/blob/master/lib/prestashop/mapper/models/tax_rule_group.rb |
It's how Prestashop handle VAT in countries, take a closer look how PS handle this. Anyway, if you need to set a tax for product, I'd suggest to do something like this: Prestashop::Mapper::Tax.get_by_country('cz')['21'] # => Tax ID for given country at this rate In any case you can use low level API and make easier requests to the server.. |
Hm - but that's getting me a tax id not a "tax_rules_group" id. Low level you mean like using https://github.com/werein/prestashop/blob/master/lib/prestashop/api/connection.rb |
Actually you will get It will go thought For example you will get something like: # For all `TaxRule` in country
{
"21": 40, # => "Tax.rate": "TaxRulesGroup.id"
"15": 41
} Yes that's what I mean |
Perfect! I will give that a try. Only thing that I am still struggling with are the supplier references. The docs here are pretty slim here: http://doc.prestashop.com/display/PS16/Web+service+reference Did you just call the endpoints and try? Or how did you come up with the impl? I bet it hides behind the |
Found the model and trying like this
but getting
where are those settings are supposed to come from? |
Yes, it's behind that endpoint. I called API with
|
@tcurdt you find any solution of that? |
@Haseeb717 sorry, it's been a while - I've moved on and cannot remember the details. I do remember it was painful though :) |
Does the API support a full import/export of products including variants and maybe even images yet?
Looks like that's the "product options" case, right?
The text was updated successfully, but these errors were encountered: