We're currently developing our first Magento module, which will be used to sync with our platform. The problem comes when trying to get product "variations" configurable attributes.
Let's say that the module loads a simple product to send to our API. The result will be something like:
item = {
"id": {
"sku": "123130999"
},
"lang": "EN",
"currency": "EUR",
"category": "product",
"name": "myProduct",
"stock": "100",
"tags": ["someproduct", "sometag", "anotherone"],
"description": {
"short": "Here is a short description.",
"long": "And there's a long description."
},
"images": ["http://img.domain.com/myproduct-1.png", "http://img.domain.com/myproduct-1.png"],
"attributes": {
"model": "MP34135",
"dimensions": "25x15x0.7cm"
},
"price": {
"final": "25000",
"market": "22500",
"cost": "19900"
}
}
I've managed to get that working already, but if the product is configurable we need another field to be passed. This field must contain product "variants", such as color, size, etc... Which will add something like that to the previous item:
variants : [
{ "id": {"sku": "123130999"},
"attributes":{"color":"black"},
"price":{ discounted: 19900, min: 15000 }
},
{ "id": {"sku": "123130998"},
"attributes":{"color":"white"},
"price":{ discounted: 29900, min: 25000}
}
]
That's what I'm not able to manage. So my question is, which is the best way to get, for each simple product related to a configurable one, the attributes that can be "configured" at front in order to get the final product (i.e: color: black, size: small).
Thanks!