cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all products to show in a category

SOLVED

How to get all products to show in a category

Hey guys, this is my first rodeo with ecommerce and Magento. So far I'm loving Magento (for the most part).

 

One of the problems I'm running into is some kind of limit set on the amount of results outputted for each category.

 

For example, lets say I have a category with 1000 products. If I view that category page it might only show me a total of 500 results, it will say now viewing 1-32 products out of 500. When it should say "out of 1000".

 

Normally I wouldn't care however I have a LOT of products and when it limits the total number shown, my layered nav is affected too. So now if I have 40 pairs of red boots, but this category is only loading 500 skus, my layerd nave might only say I have 20 pairs of red boots and if I were to click it, it would only show me the 20, not the 40, so this invites problems.

 

I wanted to fix this but couldn't find the setting to do so. I saw something about "Max Query Length" in store settings but didn't want to mess with that.

 

Looking forward to some assistance. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to get all products to show in a category

You're probably running Magento v2.1.3 / v2.1.4 which is confirmed issue with reindexing. In order to solve it, create custom module with two files:

app\code\Custom\Catalog\etc\di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Catalog\Model\Indexer\Category\Product\Action\Full" type="Custom\Catalog\Model\Indexer\Category\Product\Action\Full" />
</config>

app\code\Custom\Catalog\Model\Indexer\Category\Product\Action\Full.php

namespace Custom\Catalog\Model\Indexer\Category\Product\Action;

/**
 * Class AbstractAction
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class Full extends \Magento\Catalog\Model\Indexer\Category\Product\Action\Full {
    /**
     * Check whether select ranging is needed
     *
     * @return bool
     */
    public function isRangingNeeded() {
        return false; // By default true, due to indexing issue making it false
    }
}

After that, perform:

php bin/magento cache:clear
php bin/magento indexer:reindex catalog_category_product

And your issue should be solved.

This is temporary fix for the issue, until Magento solves the way how range() is performed for splitting product list during reindex.

 

If you're not familiar with creating Magento modules, then just edit vendor/magento/module-catalog/Model/Indexer/Category/Product/AbstractAction.php, find isRangingNeeded() function and change it to return false:

    public function isRangingNeeded() {
        return false;
    }

Keep in mind that this is not bright idea since it will be overridden by next Magento update. But if Magento solves the issue in next release, then everything will be fine for you.

 

If this response was helpful to you, consider giving kudos to this post.

If this response solved your problem, click accept as solution to help others solve this issue

 

 

If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue

View solution in original post

6 REPLIES 6

Re: How to get all products to show in a category

You're probably running Magento v2.1.3 / v2.1.4 which is confirmed issue with reindexing. In order to solve it, create custom module with two files:

app\code\Custom\Catalog\etc\di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Catalog\Model\Indexer\Category\Product\Action\Full" type="Custom\Catalog\Model\Indexer\Category\Product\Action\Full" />
</config>

app\code\Custom\Catalog\Model\Indexer\Category\Product\Action\Full.php

namespace Custom\Catalog\Model\Indexer\Category\Product\Action;

/**
 * Class AbstractAction
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class Full extends \Magento\Catalog\Model\Indexer\Category\Product\Action\Full {
    /**
     * Check whether select ranging is needed
     *
     * @return bool
     */
    public function isRangingNeeded() {
        return false; // By default true, due to indexing issue making it false
    }
}

After that, perform:

php bin/magento cache:clear
php bin/magento indexer:reindex catalog_category_product

And your issue should be solved.

This is temporary fix for the issue, until Magento solves the way how range() is performed for splitting product list during reindex.

 

If you're not familiar with creating Magento modules, then just edit vendor/magento/module-catalog/Model/Indexer/Category/Product/AbstractAction.php, find isRangingNeeded() function and change it to return false:

    public function isRangingNeeded() {
        return false;
    }

Keep in mind that this is not bright idea since it will be overridden by next Magento update. But if Magento solves the issue in next release, then everything will be fine for you.

 

If this response was helpful to you, consider giving kudos to this post.

If this response solved your problem, click accept as solution to help others solve this issue

 

 

If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue

Re: How to get all products to show in a category

I tried the steps above, I tried to do the module thing however I don't know how to create a module, so just using the instructions and creating the files above that you mentioned bricked my server. I just get errors now.

 

I am trying to get your second solution to work however I can't find AbstractAction.php.

 

It's not listed in the filepath location you mentioned. I have a search going on in my FTP now for it.

Re: How to get all products to show in a category

I used the second method and it's currently working.

 

The file path was this though:

 

Magento\vendor\magento\module-catalog\Model\Indexer\Category\Product

Re: How to get all products to show in a category

@pjr710 Great, I'm glad it worked. If my post helped you about fixing the issue, please accept that post as solution in order to help others to fix it the same way.

If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue

Re: How to get all products to show in a category

@Sinisa I accepted it as a solution. Thanks so much.

 

Do you have any idea why my original site would stop working when I tried the module solution? I deleted all my changes and still get the same error.

 

This is the error:

 

There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: 1318506757017

Re: How to get all products to show in a category

Paste me content of magento/var/report/1318506757017 file. It consists information about the error.

 

In mean time, try to fix it with:

php bin/magento cache:clear
php bin/magento setup:di:compile
If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue