Closed skwp closed 8 years ago
I think there's a deeper issue. This customer is showing that his category is mapped to a subcategory, yet what we're receiving on reverb is only the toplevel "electric-guitars" category. Please see screenshots
The problem might be that the more specific "Solid Body" category is not "winning" over the more generic toplevel electric-guitars category. What we're sending to reverb is:
{categories: [nil, "electric-guitars"], product_type: "electric-guitars"}
What we should be sending: {categories: ["solid-body"], product_type: "electric-guitars"}
@dunagan5887 if you're feeling up to it, could use your eyes on this
Not sure why "nil" is being sent, that's definitely not right. As for "Solid Body" not taking precedence over "Electric Guitars" I hadn't gotten around to establishing precedence for deeper subcategories yet, that seems to be one of the fixes here. As for the "nil" value I would need a database dump of their site to figure that one out, potentially their codebase too
I'm seeing how the "nil" happened now, I'll address that. Something to consider: In terms of taking the "deepest" category, should I take the deepest Magento category, or the deepest Reverb category? For instance:
Magento category structure: Guitars > Acoustic Guitars > Left-handed Reverb category mappings: Acoustic Guitars > Left-handed
Magento Acoustic Guitars mapped to Left-handed Magento Left-handed mapped to Guitars
Obviously this is a very contrived example, but it details the different between Magento nested level and Reverb nested level. Should the deepest Reverb category be used?
Also, you originally said that only one category should be passed in ideally, correct?
There should be up to two categories passed and they should be the deepest reverb categories. A reverb product_type should never be passed into the categories field. So if they only map to "electric-guitars" then categories would be blank. If they map to electric-guitars and hollow-body then electric-guitars is the product_type and hollow-body is in categories.
This issue was fixed incorrectly, please see comments on https://github.com/reverbdotcom/reverb-magento/pull/166
Reverted again (1bb9bf6)
I think there are a number of bugs here:
I apologize for our confusing API here...let's talk through it in person
Here is how I think it's best spelled out
basically if someone maps something to "Pro-Audio" and "Microphones" then I expect "pro-audios" in the product_type field and "microphones" in the categories array
Before I create a PR for this update, please verify that the following below are the desired functionality:
Product mapped to Pro-Audio: "categories":[],"product_type":"pro-audios"
Product mapped to Pro-Audio > Microphones: "categories":["microphones"],"product_type":"pro-audios"
Product mapped to Pro-Audio and Pro-Audio > Microphones: "categories":["microphones"],"product_type":"pro-audios"
Product mapped to Pro-Audio, Pro-Audio > Microphones and Pro-Audio > Monitors: "categories":["monitors","microphones"],"product_type":"pro-audios"
Product mapped to Pro-Audio and Parts: "categories":[],"product_type":"pro-audios"
Product mapped to Pro-Audio, Parts and Pro-Audio > Monitors: "categories":["monitors"],"product_type":"pro-audios"
Product mapped to Pro-Audio, Parts and Parts > Necks: "categories":["necks"],"product_type":"parts"
Product mapped to Pro-Audio, Parts, Pro-Audio > Monitors and Parts > Necks: "categories":["monitors"],"product_type":"pro-audios" ^ The order of precedence here is currently very arbitrary; it is the reverse order in which the Reverb categories where loaded from the complete categories JSON (due to mysql primary key loading and PHP usort() execution)
Those examples look good. Order of precedence in the case of conflicts doesn't really matter so whatever is easier.
When a magento user maps his category to a top level category like "electric guitars", we send this to reverb:
"categories":["electric-guitars"],"product_type":"electric-guitars"
This is strictly speaking not correct and the API rejects it. The
categories
field should only contain subcategories. If no subcategories are provided, we should only send the product type.I will attempt to fix this on the API side so it's more permissive, but it should also be patched in magento