7

I installed a fresh magento2, and top categories are working, but for sub-category, there is no product showing up in frontend even thought I assigned products to these sub-categories.

It's always said "We can't find products matching the selection."

Where can I find the code in Magento 2 that's responsible for displaying products so I can diagnose this in a programatic manner?

Alana Storm
  • 164,128
  • 91
  • 395
  • 599
Zike
  • 67
  • 1
  • 1
  • 4
  • Welcome to Stackoverflow! This question is off-topic here, since SO is a site dedicated to programming questions. Please take the [introductory tour](http://www.stackoverflow.com/tour). Furthermore, your question lacks basic information, like version used and alike. You might want to read [How do I ask a good question](http://stackoverflow.com/help/how-to-ask), which enhances the probability for getting a useful answer. You might find [ESR](https://en.m.wikipedia.org/wiki/Eric_S._Raymond)'s essay [How To Ask Questions The Smart Way](http://catb.org/~esr/faqs/smart-questions.html) helpful. – Markus W Mahlberg Nov 25 '15 at 22:51
  • 1
    I'm voting to close this question as off-topic because Stack Overflow is a [programming-related](http://stackoverflow.com/help/on-topic) Q&A site. Your question is not about programming. Perhaps you should post it on http://magento.stackexchange.com instead? – Enigmativity Nov 25 '15 at 23:29

6 Answers6

4

To show the product, check if the product following options:

  1. General->Status = Enabled
  2. general->Visibility = Catalog,Search
  3. Inventory->Qty > 0
  4. Inventory->Stock Availability = In Stock
  5. Websites = checking your site
  6. Catgories = checking your category.

If you want checking product to subcategory, go to Catalog->Manage Categories->Select your category, open tab Display Settings and change option "Is Anchor" to "Yes". Save category.

EchoGlobal.tech
  • 694
  • 4
  • 8
3

You can try reindexing.it works if these things all set

1.General->Status = Enabled

2.general->Visibility = Catalog,Search

3.Inventory->Qty > 0

4.Inventory->Stock Availability = In Stock

5.Websites = checking your site

6.Catgories = checking your category.

Rahul Singh
  • 199
  • 1
  • 3
  • 13
3

Please run the following command in your commandline:

php bin/magento indexer:status

If one of the indexes is "Processing" then go to your MySQL database and go to the indexer_state table. You will notice that one of the values is "Working" while the rest is "Valid"

Set Working to Invalid and reindex again. The best way to do this is to run the following Query:

update magento.indexer_state set status='invalid' where status ='working'

Good luck!

Tristan
  • 33
  • 5
3

Sub-category Product show problem solution as you need to follow as below:

Magento 2 Admin==> Products==>Category==> Sub Category==> Design ==>Use Parent Category Settings==>Checked Here

enter image description here

matinict
  • 2,411
  • 2
  • 26
  • 35
1

This is due to reindexing issue.

app\code\Modules\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="Modules\Catalog\Model\Indexer\Category\Product\Action\Full" />
</config>

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

<?php 
namespace Modules\Catalog\Model\Indexer\Category\Product\Action;

/**
 * Class AbstractAction
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/

class Full extends \Magento\Catalog\Model\Indexer\Category\Product\Action\Full {

    public function isRangingNeeded() {
        return false; // It was "True" as default setting.
    }
}

Then, we should run this command.

php bin/magento cache:clean
php bin/magento indexer:reindex

Finally, we got whole 2000 products on our category page instead of previous 340 products on frontend page. Also, the "Product category" tab on index management is just updated from date of version upgraded to current indexing date and time.

Great experience!

Hope this will help many developers and owners.

Igor Revenko
  • 419
  • 1
  • 4
  • 16
0

I had a similar problem, product showed up in the parent category, but not in the originally assigned subcategory. I solved it by hitting the "Save" button in the subcategory and/or (not sure if both necessary) parent category edit page.

  • yes that also works, well a manual reindex, but for me it is much simpler to hit just save in the category page rather than open up the shell coammand, login, change user, run reindex manually and renew the cache. Problem is discussed over here in more detail https://github.com/magento/magento2/issues/2855 – Tobias Kess Apr 23 '17 at 08:37
  • that's not a correct way to do. What for new products ? Inventory change ? etc... In-fact you could schedule indexing as a cron based on your desire time so that your data is properly indexed. – rajatsaurastri Apr 24 '17 at 13:33