bsmither Posted September 29, 2021 Share Posted September 29, 2021 Ok. So, even though I see directives in the HTTP headers that any page cache mechanisms that might exist between your web server and my browser to not cache any of your pages, I am wondering if there is actually something like that interfering. Please ask your hosting provider if they have implemented or have acquired the services of any sort of page caching application. If not, we can add some diagnostic statements to the code to try to find what is happening. Link to comment Share on other sites More sharing options...
violinman Posted September 29, 2021 Author Share Posted September 29, 2021 It is a dedicated server just for my web sites but I will log in to admin and check, I will not get a chance to do so though until tomorrow morning as it is 10 pm here now. Link to comment Share on other sites More sharing options...
violinman Posted September 30, 2021 Author Share Posted September 30, 2021 The only cache on my server is opcache which is specifically for the PHP. Link to comment Share on other sites More sharing options...
bsmither Posted September 30, 2021 Share Posted September 30, 2021 Last I looked, I was repeatedly getting WP82, WP80, WP71, WP47, WP46, and WP33. Now, today, I am getting WP82, WP80, WP71, WP46, WP29, and WP27. I also paying attention to the Featured Product, which does change for every new page request. Based on that, I can positively conclude that, at least the Featured Product, is not coming from a cache. So, shortly I will have some diagnostic code to be added to the snippet. Link to comment Share on other sites More sharing options...
violinman Posted September 30, 2021 Author Share Posted September 30, 2021 At the moment it is back on the default setup and have only three bows as latest products to force it to pick up three violins! The default takes the Lates Products from the highest number in depending order which is really quite bizarre! Link to comment Share on other sites More sharing options...
bsmither Posted September 30, 2021 Share Posted September 30, 2021 Bring that snippet back up for editing. Replace the PHP Code with this: <?php $cat_1_id = 1; // Adjust to suit $cat_2_id = 2; // Adjust to suit $cat_1_count = 3; $cat_2_count = 3; // Get all product_id values in cat_1 $products_from_cat_1 = $GLOBALS['catalogue']->getCategoryProducts($cat_1_id,false); // Returns list of products keyed with product_id. $GLOBALS['debug']->debugTail(array_keys($products_from_cat_1), 'products_from_cat_1'); // Filter out any product that does not have the 'latest_product' flag set. foreach ($products_from_cat_1 as $prod_cat_1_key => $prod_cat_1) { if (!$prod_cat_1['latest']) unset($products_from_cat_1[$prod_cat_1_key]); } $GLOBALS['debug']->debugTail(array_keys($products_from_cat_1), 'filtered_products_from_cat_1'); // Select maximum of cat_1_count random elements to latest_products_group_1 $random_product_keys_from_cat_1 = array_rand($products_from_cat_1, min($cat_1_count, count($products_from_cat_1))); $GLOBALS['debug']->debugTail($random_product_keys_from_cat_1, 'random_product_keys_from_cat_1'); // Get all product_id values in cat_2 $products_from_cat_2 = $GLOBALS['catalogue']->getCategoryProducts($cat_2_id,false); // Returns list of products keyed with product_id. $GLOBALS['debug']->debugTail(array_keys($products_from_cat_2), 'products_from_cat_2'); // Filter out any product that does not have the 'latest_product' flag set. foreach ($products_from_cat_2 as $prod_cat_2_key => $prod_cat_2) { if (!$prod_cat_2['latest']) unset($products_from_cat_2[$prod_cat_2_key]); } $GLOBALS['debug']->debugTail(array_keys($products_from_cat_2), 'filtered_products_from_cat_2'); // Select maximum of cat_2_count random elements to latest_products_group_2 $random_product_keys_from_cat_2 = array_rand($products_from_cat_2, min($cat_2_count, count($products_from_cat_2))); $GLOBALS['debug']->debugTail($random_product_keys_from_cat_2, 'random_product_keys_from_cat_2'); // Combine latest_products_group_1 and _2 $latestProducts = array_intersect_key($products_from_cat_1, array_flip($random_product_keys_from_cat_1)) + array_intersect_key($products_from_cat_2, array_flip($random_product_keys_from_cat_2)); $GLOBALS['debug']->debugTail(array_keys($latestProducts), 'latestProducts'); In admin, Store Settings, Advanced tab, set CubeCart's "Enable Debugging" mode to Enabled. In the next text entry field, enter your local IP address (www.showmyip.com). Enable the snippet. Test the Homepage. At the bottom of the page will be a grey diagnostic section. Following the list of SQL queries will be a series of captions with their respective contents. Does anything look strange? Link to comment Share on other sites More sharing options...
violinman Posted September 30, 2021 Author Share Posted September 30, 2021 Hello, once again it is 10 pm. so will do it in the morning and get back to you later during the day, many thanks. Link to comment Share on other sites More sharing options...
violinman Posted October 1, 2021 Author Share Posted October 1, 2021 Hello again, I did try the new code and enabled the debugging but still not working correctly and also no de-bugging info appeared. It is possible there is a problem with my setup that is causing problems. I tried a plugin from Havenswift which seems to be a good compromise, it is called "Advanced Sorting" it is a bit clunky but I can pick the items I want to be displayed in "Latest Products" it is not random so it displays what I pick but it is a big improvement on the default method so I will go with that for now. What is interesting is that the default behaviour is to pick from the highest to lowest numbers, and not randomly but just in decending order so the only way I could have 3 bows and 3 violins was to make sure their are only 3 bows ticked as latest products, if there were for example 5 bows I would get 5 bows and 1 violin. Very clunky but the plugin from Havenswift is a good workaround for now. I appreciate your efforts which may work just fine on someone else's site! Link to comment Share on other sites More sharing options...
bsmither Posted October 1, 2021 Share Posted October 1, 2021 You said: "no de-bugging info appeared". Are you saying that there was no grey area at the bottom of the page containing at least a list of all the SQL queries made for that page? Did you enter your own correct IP address in the following text entry field? (Your workstation computer's public IP address, not your website's IP address.) Link to comment Share on other sites More sharing options...
violinman Posted October 1, 2021 Author Share Posted October 1, 2021 Actually you are right, I still had my IP from my old computer so yes debugging info, masses of it does not appear but I think I will continue with the Havenswift plugin as it is the easiest option for now! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.