getcandy / candy-api

GetCandy v1 E-Commerce API
https://getcandy.io
Apache License 2.0
445 stars 115 forks source link

Basic idea to try detect if attribute data needs mapping or not (unte… #395

Closed glennjacobs closed 2 years ago

glennjacobs commented 3 years ago

Untested, just an idea at present.

Want to allow creation and updating of the attribute_data Eloquent field using the same consistent format. Currently, creation routines use a different format, and the mapping function adds in the channels which are not provided.

The idea is we test the attribute data array to see how deep it is. If it is "shallow" then we assume it requires mapping, but if it's the correct depth (attribute > channel > language) then we assume the attribute data is already in the correct format. I guess we could go further if we wanted by checking for valid locales or similar.

alecritson commented 3 years ago

Yeah I think it would be handy to have. It's something that has tripped people up and currently not that nice. Maybe if we get some tests in (even if they fail) it'll be clearer to see what we're doing etc etc