ShoppinPal / vend-tools

A command-line-interface (CLI) which allows you to easily perform custom tasks for your vendhq.com instance
http://shoppinpal.github.io/vend-tools/
GNU General Public License v2.0
3 stars 3 forks source link

Product CSV bools #8

Open jtrotsky opened 9 years ago

jtrotsky commented 9 years ago

In a Vend product CSV, there are some strict rules for what is a valid import to a Vend store. The two boolean columns in the CSV are active and track_inventory.

Vend will only accept a 1 or 0 for bools, true and false are not valid. (this is our error.. but it exists either way.)

Currently vend-tools downloads products with active and track_inventory like this:

screenshot 2015-03-04 09 48 27

It needs to looks like this:

screenshot 2015-03-04 09 48 51

Should be a simple fix. I don't know how it should look here, but this is what I did (in Golang):

// Both must be integer bools instead of the default strings.
a := 0
if *product.Active {
    a = 1
}
active := fmt.Sprintf("%v", a)

t := 0
if *product.TrackInventory {
    t = 1
}
trackInventory := fmt.Sprintf("%v", t)
pulkitsinghal commented 9 years ago

@jtrotsky - Thanks! Yes, this should be accomplishable.

@elbrando - You use this feature quite a bit to print new barcodes right? By piping the data into your 3rd party software every so often ... correct? So, I want to make sure that if I make the changes suggested above ... replace true/false with 1/0 ... it should not break your process ... will it? Let us know.

pulkitsinghal commented 9 years ago

I'm thinking of an explicit flag to enable the functionality, something like:

  1. --formatForVend true, or
  2. --vendCompatible true, or
  3. --vendFriendly true, or
  4. --vendFormatted true, or
  5. --dataFormat vend
elbrando commented 9 years ago

Yes, we use this a lot. The "true/false" vs. "0/1" thing is what it is. Should the field be true/false? Sure. Can we deal with the bifurcation? Sure.

Personally, I'd rather deal with the 0/1 until Vend makes it evaluate true/false, as it should. ;)

Mostly, I just wanted to use "bifurcation" in a meaningful way today. Thanks.

pulkitsinghal commented 9 years ago

Soooo ... (god i'm dumb)... @elbrando you want 0/1 convention right?

jtrotsky commented 9 years ago

@pulkitsinghal I like the idea of a --vendFriendly flag.

Personally, I'd rather deal with the 0/1 until Vend makes it evaluate true/false, as it should. ;)

Vend currently only evaluates 1/0, but yes it it definitely should take true/false also. :)