Jump to content

featured product, best seller, and on sale items are static


Recommended Posts

Let's review:

In admin, Store Settings, Features tab, Sales section, "Number of sale items to display" is 6 (as I count them on the homepage), but there are many more items on sale. On the Layout tab, Popular and Latest Products section, "Number of popular products to display" is set to 1, and "Source data for popular products" might be Product Sales. In admin, editing a product, General tab, Basic Information section, "Include in featured products" checkbox is regularly checked.

From what I see in the code, the items in the Sale Items box are from what the database sends back in its standard unsorted order - that is, the first six records found in the database table that satisfies the WHERE clause (status = 1, the item has an actual or calculated sale price, and customer group pricing does not remove it from being on sale). The query sent to the database does not include any randomization function.

The item in the Best Sellers box, because the selection parameter does not change, will always be the same item until some other product acquires more sales or more views (depending on the admin setting). In admin, Maintenance, Catalogue section, "Reset all all product view counts" can be used to try to get more randomness.

The item in the Featured box is a random selection among all those items where status=1 and featured=1. However, for each product randomly chosen from this group, a test is made to make sure the item is assigned to a category that is enabled, to a maximum of 15 tries. So, arguably, with a sufficient number of products that have "Include in featured products" setting checked, it should change.


Edited by bsmither
Link to comment
Share on other sites

thanks for your advice. somehow the featured product is stuck at the same product, even after I removed it from the featured list. Just to be clear, we also have more than one product set to be featured. it is not due to the file box.featured.php as well, as we have replaced the file with another from a website that we know the featured works.


Link to comment
Share on other sites

Contact your hosting provider and ask if your account has any sort of opcode cache, or a cache that could return the same result from the PHP function mt_rand(), or the output of a method in a class, or a function, or even an entire script file.

Meanwhile, in admin, have CubeCart clear its internal cache. If there is a database query that is being read from cache that has obsolete data in it, this will clear that out.

You might also use an external database utility (such as phpMyAdmin available in your hosted account's control panel) to execute the following query directly against the CubeCart database:

SELECT product_id FROM `CubeCart_inventory` WHERE CubeCart_inventory.status = '1' AND CubeCart_inventory.featured = '1' ;

BE AWARE that your database may have prefixes that are part of the table names. Use those prefixes when executing the above query. Note how many rows are returned.

In admin, Store Settings, Advanced tab, enable Debug Mode, and enter your local IP address in the next field (www.showmyip.com). Save.

The next page shown should have the debug section below the page of content (pre-CC6.5.x) or in a popup window (post-CC6.5.x).

View the storefront. Near the bottom of the debug listing, in the list of database queries, look for the query that has the SELECT query as shown above. (Mine is query #202 but yours will be different.) The next three queries should be:

SELECT CI.* , C.status FROM `CubeCart_category_index` AS CI, `CubeCart_category` AS C WHERE CI.product_id = '5' AND CI.cat_id = C.cat_id ORDER BY CI.primary DESC
SELECT * FROM `CubeCart_inventory` WHERE CubeCart_inventory.product_id = '5' LIMIT 1;
SELECT COUNT(*) AS `Count` FROM `CubeCart_inventory` WHERE CubeCart_inventory.product_id = '5' ;

where the 'product_id' should change from page load to page load. (If using Firefox, you may need to close the popup before each page request. Firefox seems to have implemented some sort of security measure that denies access to an already opened, but disconnected, popup window.)


Link to comment
Share on other sites

On 6/11/2023 at 11:08 PM, bsmither said:

thanks for your help. what code uses this? I think this might be the issue. During the process of performance tuning, I might have deleted the code that uses these.

Link to comment
Share on other sites

These are the names of hooks. Hooks are used to identify additional code (plugins and snippets) where such code can add, delete, and modify the data being worked on, or do any kind of other work.

This additional code exists in files as part of plugins (plugin hooks are enumerated in the database table CubeCart_hooks), or stored in the database directly (CubeCart_code_snippets).

If you deleted the code where these hooks are located, then there would be no Random/Featured Product to show.

But to answer your question, the hook statements are in the /classes/gui.class.php file, in the function:

     * Display featured products box
    private function _displayRandomProduct()


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...