Jump to content
Claudia M

Products per page

Recommended Posts

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

Edited by Claudia M

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

That edit probably explains why some pages sometimes return less than the default number of products.

Share this post


Link to post
Share on other sites

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) {

 

Edited by bsmither

Share this post


Link to post
Share on other sites

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;
                }

 

Share this post


Link to post
Share on other sites

Put a semicolon after the new line:

$where = " AND INV.available > 0";

 

Share this post


Link to post
Share on other sites

"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.

1493376282_Captureseelisting.PNG.f258eccb76f3dd3f41c7db6773ebae7f.PNG1342878438_Captureproductsold.PNG.5452af0cf277e5380e6dd26edb39c0ee.PNG

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

Double check that this product has the Available checkbox cleared.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!!!!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Guest
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...