Newly-created products in Magento 2 not appearing on front of site

An interesting situation cropped up last week on Pretty Personalised, a store we migrated to Magento 2 a few weeks ago. The products were all moved across automatically, and a new product was then created by duplicating an existing product. But it stubbornly refused to appear on the front of the site – so we compiled a quick checklist to see why not.

First up was to use the command line (for sake of ease) to reindex the database and flush the caches :

bin/magento indexer:reindex
bin/magento cache:flush

If no joy there, they it’s possible – although unlikely – that the indexer could benefit from a reset, so try :

bin/magento indexer:reset

and then repeating the first step again.

If no joy at this point, then it’s a case of moving to the admin panel and looking at the following aspects of the product :

1. Is it enabled?
2. Is its visibility set to “Catalog / Search”?
3. Does it have stock?
4. Is its stock status set to be “In stock”?
5. Is it set to appear in the website?

If any of these values need to be changed, then once changed repeat the first step again.

Now, in this case, we did all this, but the product still refused to show. The issue – and therefore the solution – lay in the import process. Because the Magento 1 store had multiple store views, whereas the Magento 2 store had a single store view, we didn’t initially consider dropping down to the website or store view levels to see what the settings were there. But once we did, we realised that the status of the product at that level was set to Disabled.

The fix was to edit the database to remove all product attribute values that were specified at the store view level – after a quick check to ensure that (bar this product) they were no different to the values in the default configuration scope.

So, for each of the catalog_product_entity-* tables it was a case of running the following query :

delete from tablename where store_id = 1;

(In this case the store_id was 1, but you could also use ‘where store_id != 0″ instead, if there are multiple store_id values) Note, of course, that if your store does have multiple store views, and needs them, then this is not the solution for you.

After that, back to step one again, and all showed up as it should.