segment-boneyard / analytics-magento

[DEPRECATED] The hassle-free way to integrate analytics into any Magento store.
15 stars 19 forks source link

Booleans and numbers #32

Closed ianstormtaylor closed 10 years ago

ianstormtaylor commented 10 years ago

It looks like certain traits and properties are really booleans, but Magento is storing them as 0 and 1. We'd want to convert the ones that are supposed to be booleans into proper booleans when sending them to the API. I noticed this for is_active and others.

The same goes for numbers, mostly floating point, for things like price and other dollar amounts.

astorm commented 10 years ago

Ian, I'll make an attempt here, but you're going to want your system to be ready to accept and convert these things. PHP's pretty loosey goosey with types, and while we can cast things we identify now, Magento's configurable nature means you're going to see field names we don't know about, and can't guess at the type of to correctly cast.

astorm commented 10 years ago

Got some of these done in

https://github.com/segmentio/analytics-magento/issues/45

and

https://github.com/segmentio/analytics-magento/issues/43

Still need to handle booleans.

astorm commented 10 years ago

OK, we should be set here. I've added a new central helper method to sanitize any data array for a known list of boolean Magento values. As a reminder though, Magento is a highly customizable system, and it's very likely we'll see other values (values created by the end users which we can't possible guess) that are intended as booleans sent through as 0,1,"0", or "1". You'll want to have the Segment system ready to accept this in a non-crashing way (postel's law, etc.)