• On my website, whenever I select a product, I can see some related products on the bottom. I understand that these related products are selected by the WooCommerce default behavior of selecting random products by category. However I am seeing the same related products no matter what product I select. For example, I have about 100 items in my Fall category. No matter what product I chose, I always get the same items in the “Related Products” at the bottom of the page. Isn’t this suppose to be a random selection of products within the category?

    https://www.ads-software.com/plugins/woocommerce/

Viewing 13 replies - 16 through 28 (of 28 total)
  • Thread Starter trader4300

    (@trader4300)

    That is interesting. Do you have any tags associated with your products?
    What is your website?

    Whether WooCommerce is flawed or not depends on what is meant by “random”. In the sense that the products in the pool are displayed in a random order, then yes they are, and WC works fine. Conversely, if we think that random should mean that the selection of products for the pool is random, then no its not. They are in id order.

    I can’t say why get_related() is returning un-related items. The relevant code is in abstract-wc-product.php at lines 1245 and 1481. Its supposed to pick products with at least one matching category or at least one matching tag, but there is no sorting. The code looks OK to me but debugging it is beyond me.

    yes, I originally put everything into categories but the same 4 products would always display in a different order on every product regardless of there category, which where the first 4 products in the shop. I tried adding tags to all the products to see if this would help filter them but no change.

    I then added this code to allow more products, but now it still picks any 4 random products from the shop again regardless of the category, there’s just more products to randomly pick from now.

    Currently my site is still local, I may have to put it live to be able to show others and get help as I can’t seem to figure it out.

    Just a thought, is there a way to make the related products filter under sub-categories?

    My site is for a camera shop, so my categories are by ‘New’ and ‘Used’ Cameras, and then brands as sub-categories under the two.

    Would it be that when I click on any product under ‘Used’ cameras, regardless of the sub-category brand it will display anything under ‘Used’ as related?

    I think WooCommerce related products isn’t working the way it should at the moment, showing always the same related items (the first 4 products we published on our site with a certain tag). That’s no good, also not for SEO-purposes.

    I already posted about this: https://www.ads-software.com/support/topic/better-related-products?replies=5

    WC’s Mike Jolley advised me to filter the query but I don’t have a clue how to do so. (?) It would already be a big improvement if I was able to make WC come up with the last modified related items or the last published.

    With the code above we could make the pool bigger, but I am afraid this will give much more load?

    Thread Starter trader4300

    (@trader4300)

    YURI, that is how mine used to work before I used the code presented on this forum. I do not see any load issues. Not sure why Mike gave such a vague response. He is usually very helpful.

    rookdesigns

    (@rookdesigns)

    Hey guys, above code wasnt working for me although I have no idea why, it looks like it should do it, but also no other effects to related products I was trying in functions.php seemed to work. I then found this plugin, no idea how I missed it: https://www.ads-software.com/plugins/woo-related-products-refresh-on-reload/

    I know using a plugin isnt ideal for such a small change, but it’ll do for now until I can work this out. Anwyay just thought I let people know.

    Harry

    Hi guys,

    Thanks for trying to solve this.

    @lorro your explanation with the increase in the pool makes sense, however would it be possible to keep the same pool but to load the most recent products instead of the first ones that were created?

    Thanks

    @mike_ostro
    Yes, it would be necessary to copy and customise the build_related_query function in includes/abstracts/abstract-wc-product.php line 1503. Bit heavy for me.

    Thanks Lorro, we have updated to 60 from the 10 in your code and FINALLY we see other than initial 10 of that category.
    However, now it shows same latest products instead of same first ones we added. Regardless of product we look at in that category (some are workshops for dresses, pants, shirts etc under that software training category)

    GOOD NEWS is that after placing your code it may have acttivated something finally in WC, so that after remving it from child theme functions file all works as a charm!

    Just like should have.

    We use The7 v2 theme, and no CDN yet, but the incredibly good WP Rocket caching. It does not hinder WC in any way. We have a lot of speed optimizations and dev, so of course didn’t want to tinker making things slow with heavy queries after paying to make it load faster…

    For some reason placing your code and changing that number and then removing it did a magic trick. I was worried cleaning cache and OPcache would ruin it but it did not. Bloody amazing!

    All rotate nicely as before but finally we see more than initial 10 all the time everywhere. WOOOOOOOW! Thank you.
    This stuff should be built into WC to trigger correct behavior.

    Oh no, now after 5 minutes it is back to bad behavior as before ??

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    @tekgirlymama
    Something that works for a short time and then doesn’t sounds like a cache issue. Do you have a cache plugin, if so suggest delete cache items and turn off caching while developing.

Viewing 13 replies - 16 through 28 (of 28 total)
  • The topic ‘Related Products do not change’ is closed to new replies.