Hey tP! I put this weirdness in as support because I don't want to hold up stable release but it is interesting enough to mention.
With just one of my products I find upsell items being truncated by one, i.e. 6 items set to display but only 5 do. This one is part of my largest product class in terms of items and is a sub item in taxonomy, don't know if either of those facts has bearing on why that is the one affected. I also have some other classes/taxonomy items that have fewer products than configured so not 100% sure that it wouldn't happen with other products either, but have not seen it with any others that do have enough products.
Here is an example with the affected product class: http://www.rainmanweather.com/site/catalog/Wireless-Thermometers select any item and 5 upsell items are displayed, it is configured for 6.
furthermore, adding to cart you will see 4 items displayed, the cart is configured to display 5.
any other product, say go to http://www.rainmanweather.com/site/catalog/Forecast-Stations and you see the correct number of items (6 in product view, 5 in cart).
Is odd, no?
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | uc_upsell_568164_1.patch | 2.98 KB | torgospizza |
| #15 | uc_upsell_568164.patch | 2.98 KB | torgospizza |
Comments
Comment #1
torgospizzaThat's quite odd... and I can't say I've ever seen that behavior.. I'll look into it some more.
Just so we're clear, it *only* does this when you're only doing the "Override" for taxonomy-related products? And it only does it for certain vocabs? Seems pretty strange... have you run Cron lately? Perhaps the array of taxonomy-related nodes needs to be rebuilt?
Comment #2
Rainman commentedOK yeah good on the clarification, actually it *only* does it when doing the "Add" for Related Products based on Taxonomy. I tried Override after seeing this and the issue is not present with that method.
To make sure I have my terminology correct, it is only happening to a single Term within the Vocabulary.
Cron runs on a pretty regular basis, I ran manually no change. I also went into both the vocabulary and terms and saved to see if that would change, it didn't. not sure how else to rebuild the array.
Comment #3
torgospizzaI think this might be a taxonomy term issue. My guess is that perhaps it's going by Term, and not Vocabulary. Can you explain to me a little more how your Catalog vocabulary is setup? In my test setup I have a "Products" vocab, with two terms: "Doodads" and "Widgets."
When I set the system to "Add" and I had 6 or 7 products belonging to the "Widgets" term, I got 5 products, as I would expect. The only way I could get this to NOT happen was when I didn't have enough products belonging to that term id. One way you can check is, in the uc_upsell_core.inc file, go to the function called uc_upsell_nids_by_term. Then before the "return $nids" line, add this:
Then refresh a node page. That will show you all of the nodes it got back from the database call that basically is saying "what's the node we're looking at, and what term does it belong to?" From there it strips out the current node, because you don't want the product you're looking at to show up in the "related" block. In my case I was able to see that when my current node got stripped out, I was missing 1 product - but only because I didn't have enough associated with the "Widgets" term to begin with.
Give that a shot - add more products to one specific product's term. If that seems to be the case, maybe I'm being too granular with my taxonomy associations, and I need to go a level higher so that it considers parent terms as well? So for instance if "Widgets" had a sub-term called "Cubits" I wouldn't want to look at just the Cubits term, necessarily, but still stay on the parent term, which is "Widgets." Does this make sense?
Right now it still seems to work as it should, assuming you have enough products that belong to the term in question.
Comment #4
Rainman commentedOK well hmm here is what the set message brought back: got nids from db: (ergo nada!)
The vocab is set up exactly as you described and each term (examples above) has well over the required number of products in it
Comment #5
torgospizzaAre you still seeing this problem?
Comment #6
Rainman commentedHi, The issue is gone! Sorry, I didn't even notice when that happened. not sure if it was a release (I am using latest released now) or recently added some items to the term. either way, all clear on that one.
Thanks!
Comment #7
Rainman commentedOh, actually I am out of it.. I am using 6.x-1.19 with the issue gone, just noticed the 6.x-1.20.
Comment #8
torgospizzaThat's okay, it was only a very minor change between 1.19 and 1.20, but I want to make 1.20 the final release (frozen code) so that I can focus putting new features into 2.0.
Thanks :)
Comment #10
j0rd commentedI just upgraded from 1.15 to 1.20 and I'm having this issue as well. Off by one error.
It happens in uc_upsell_filter_types
The function is correctly filtering out the un-published node...but it's not filling it up with a random or published node (of which there are)
I tracked the issue down to this section of code, which is limiting the results too much.
If you comment out the array_slice line everything works fine. I have done so in my code. Another thing I noticed because of this slice, was the lack of randomization due to the fact that it's only randomizing off my "slice of 4" instead of out of all the related nodes.
This fix alone will not solve the problem, as we could have 1 published node and the rest are unpublished, we'll still run into the previous issue I mentioned. We should be only pulling in published nodes into the "needed" array.
Thanks a bunch for this module, it's one of my faves for Ubercart. looking forward to the 2.x branch.
Comment #11
Rainman commentedAh-Ha! very good j0rd.
as you could see by the thread we never really figured this one out. I am now guessing that I had a non published node that was then published thus "solving" the issue. coincidence with the relases.
should be easy enough to reproduce, Thanks!
Comment #12
Rainman commentedSure enough, I unpublished a product from my catalog as it was not available and upsell started truncating by one again within that taxonomy term. removing the product from the term of course fixed the issue.
I went ahead and reopened as it is a confirmed bug.
Comment #13
adamo commentedI'm seeing this as well.
Comment #14
torgospizzaCrazy - thanks for the updates and reopening the bug. I'll look into it this week, along with the other Issue I have on my radar for Upsell, and I'll release a new version soon as I can.
Comment #15
torgospizzaHere's a patch against the current 1.x dev, which I think is the same as the 1.20 (Haven't made any major commits since then). If it doesn't work let me know and I will re-roll it against 1.20.
What it does is move the "add randoms" functionality to after the node type filter. This is how it was originally meant to behave - only add randoms (which will not honor some filtering-by-type rules) only once we've filtered out too many. Make sure the "add random products" checkbox is also checked in the "Cart Pane" settings at admin/store/settings/upsell.
It seems to work in my testing but I'd appreciate some feedback :)
Comment #16
torgospizzaWhoops, latest patch had an incorrect array_merge($related) - should be array_merge($ary). Here's an updated patch.
Comment #17
j0rd commentedIf there's one thing I'm good at, it's breaking things :D
Thanks for the fix TP. This is a great module. Thanks for your hard work.
Comment #18
torgospizzaj0rd, thank YOU for your feedback and breaking stuff. That's the only way I can make anything better :)
Comment #19
Rainman commentedHey TP!
I'm burning a lil midnight oil eastcoast time on another issue, but should get a chance to test before morn, will let you know!
Comment #20
torgospizzaSounds good. Keep me posted!
Comment #21
adamo commentedThat seems to have solved the problem for me. Thanks!
Comment #22
torgospizzaSweet :)
Comment #23
Rainman commentedHey tP! Sorry it took me so long, been very busy actually using my ubercart! capitalism is alive and well this season:)
anyhow, tested with 6.x-1.20 and works just right!
Thanks!
Comment #24
torgospizzaAwesome news! I'll commit this in the next release :) Thanks for your help!
Comment #25
torgospizzaCommitted in CVS.