Claudia M Posted November 25, 2019 Share Posted November 25, 2019 I have admin/store settings/layout/ products per page set to 15. I also changed my skin/config to 15. <layout> <products> <perpage amount="6" /> <perpage default="true" amount="15" /> <perpage amount="24" /> <perpage amount="48" /> <perpage amount="96" /> </products> </layout> But look at these pages. The first page is only showing 14 products. https://www.claudiasbargains.com/bottles-jars-and-jugs.html?page=1 https://www.claudiasbargains.com/decorative-display-and-collectibles.html?page=1 https://www.claudiasbargains.com/telephones-and-radios.html?page=1 https://www.claudiasbargains.com/tins-and-containers.html?page=1 But these categories that has more than one page shows 15 products https://www.claudiasbargains.com/electric-oil-warmers.html?page=1 https://www.claudiasbargains.com/fragrances.html?page=1 https://www.claudiasbargains.com/toys-games-and-vehicles.html?page=1 Anybody know what is causing this? Thanks for any and all help Claudia I just noticed this: First Page showing 10 products. Look at the third page https://www.claudiasbargains.com/cigar-and-other-boxes.html?page=1 https://www.claudiasbargains.com/cigar-and-other-boxes.html?page=3 Link to comment Share on other sites More sharing options...
bsmither Posted November 25, 2019 Share Posted November 25, 2019 I recently assisted someone with having the skin skip over any product that was not available for purchase. For that person, the skin edit took the collection of the default amount of items per page (15), and skipped over some (none, some, or all, actually). To truly get a full collection of the default amount, making sure to query the database to take into this additional condition, will require an edit to the codebase (maybe a code snippet would do). Do you have any thing that would skip over or remove items that fail to match any additional conditions? Link to comment Share on other sites More sharing options...
Claudia M Posted November 25, 2019 Author Share Posted November 25, 2019 I was that person!!!! Link to comment Share on other sites More sharing options...
bsmither Posted November 25, 2019 Share Posted November 25, 2019 That edit probably explains why some pages sometimes return less than the default number of products. Link to comment Share on other sites More sharing options...
Claudia M Posted November 25, 2019 Author Share Posted November 25, 2019 How can that be corrected Link to comment Share on other sites More sharing options...
bsmither Posted November 25, 2019 Share Posted November 25, 2019 As of CC628, there isn't a hook available to incorporate a WHERE clause in the database query made where CubeCart gets the collection of all products that belong to the target category. As discussed, hiding out-of-stock products will also cause a 'product not found' message to display when wanting to actually view an out of stock product. This is not the same as what you want to do. Do you agree to modify the core code? If so, try: In /classes/catalogue.class.php, near line 727, find: public function getCategoryProducts($category_id, $page = 1, $per_page = 10, $hidden = false) A few lines later, find: $where2 = $this->outOfStockWhere(false, 'INV', true); On a blank line above that, add: $where = " AND INV.available > 0"; EDIT: Fixed the above. Be sure to restore the edit to the skin, just to remove any influence that may have. Oops! Forgot something. A few lines after that, find: if (($result = $GLOBALS['db']->query('SELECT I.product_id FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_category_index` as I, `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` as INV WHERE I.cat_id = '.$category_id.' AND I.product_id = INV.product_id AND INV.status = 1'.$where2)) !== false) { Change to: if (($result = $GLOBALS['db']->query('SELECT I.product_id FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_category_index` as I, `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` as INV WHERE I.cat_id = '.$category_id.' AND I.product_id = INV.product_id AND INV.status = 1'.$where.$where2)) !== false) { Link to comment Share on other sites More sharing options...
Claudia M Posted November 25, 2019 Author Share Posted November 25, 2019 After making the changes and clearing the cache I get a white screen in admin and my store. Here's the changes I made: ( and I deleted the previous code from skin/category public function getCategoryProducts($category_id, $page = 1, $per_page = 10, $hidden = false) { if (strtolower($page) == 'all') { $per_page = false; $page = false; } $where = " AND INV.available > 0" $where2 = $this->outOfStockWhere(false, 'INV', true); if (($result = $GLOBALS['db']->query('SELECT I.product_id FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_category_index` as I, `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` as INV WHERE I.cat_id = '.$category_id.' AND I.product_id = INV.product_id AND INV.status = 1'.$where.$where2)) !== false) { $this->_category_count = $GLOBALS['db']->numrows(); if (isset($_GET['sort']) && is_array($_GET['sort'])) { foreach ($_GET['sort'] as $field => $direction) { $order[$field] = (strtolower($direction) == 'asc') ? 'ASC' : 'DESC'; break; } Link to comment Share on other sites More sharing options...
bsmither Posted November 25, 2019 Share Posted November 25, 2019 Put a semicolon after the new line: $where = " AND INV.available > 0"; Link to comment Share on other sites More sharing options...
Claudia M Posted November 25, 2019 Author Share Posted November 25, 2019 "Be sure to restore the edit to the skin, just to remove any influence that may have. " Did you mean for me to remove the edit? Because now my sold items are showing in the category page with a "see Listing" and on the product page it correctly shows my modifiedThe item item has been sold. Link to comment Share on other sites More sharing options...
bsmither Posted November 25, 2019 Share Posted November 25, 2019 Enable debugging. When viewing a category, find the query that starts with SELECT I.product_id FROM and has AND INV.available > 0. Copy it to your reply. Double check that this product has the Available checkbox cleared. Link to comment Share on other sites More sharing options...
Claudia M Posted November 25, 2019 Author Share Posted November 25, 2019 here you go SELECT I.product_id FROM `CubeCart_category_index` as I, `CubeCart_inventory` as INV WHERE I.cat_id = 157 AND I.product_id = INV.product_id AND INV.status = 1 AND INV.available > 0 AND `live_from` < UNIX_TIMESTAMP() -- (0.00084900856018066 sec) [NOT CACHED] Link to comment Share on other sites More sharing options...
bsmither Posted November 25, 2019 Share Posted November 25, 2019 Double check that this product has the Available checkbox cleared. Link to comment Share on other sites More sharing options...
Claudia M Posted November 25, 2019 Author Share Posted November 25, 2019 I did before and i checked one just now and they don't. Link to comment Share on other sites More sharing options...
bsmither Posted November 25, 2019 Share Posted November 25, 2019 Well, it seems the database column for 'available' is an ENUM data type. The values it can take is a string '0' or a string '1', as opposed to integer values. That means the query needs to be very specific. Try: $where = " AND INV.available = '1'"; From the other conversation, the image capture, the right button says SOLD, but the code says "See Listing". Also, this project has not been tested for search results nor sale items. Link to comment Share on other sites More sharing options...
Claudia M Posted November 25, 2019 Author Share Posted November 25, 2019 That seems to have done it!! Don't worry about the SOLD and See Listing. That was some edits I made in the skin/category template for items on Etsy or eBay. I might put them back to stock since they don't show now either. Which I like. I don't use sale items and the search results I really don't care about. Thank you so much Brian. As always!!!! Link to comment Share on other sites More sharing options...
Claudia M Posted December 6, 2019 Author Share Posted December 6, 2019 Brian, Is there any way to exclude a certain category or two from this. I don't want it to show my sold products but I'd like for it to show my eBay and Etsy listings that aren't available for purchase in my store. I can create a special category for them. Thanks as always, Claudia Link to comment Share on other sites More sharing options...
Claudia M Posted December 6, 2019 Author Share Posted December 6, 2019 Nevermind. I figured it out Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.