0

I just migrated from Magento 1.9 to Magento 2.3.4 and I have an anchor category that should be showing all the subcategories products, but somehow it does not show any of the subcategory products.

Parent Category Display Setting: enter image description here

in my M1 site , if i go to the category page, it will show all subcategory products:

http://m1-site.local/catalog/category/view/id/1404

in my M2 site, if i go to the category page, it won't show any products at all:

http://m2-site.local/catalog/category/view/id/1404

I tried to debug it in vendor/magento/module-catalog/Controller/Category/View.php:264 :

private function getPageType(Category $category) : string
{
    $hasChildren = $category->hasChildren();
    if ($category->getIsAnchor()) {
        return  $hasChildren ? 'layered' : 'layered_without_children';
    }

    return $hasChildren ? 'default' : 'default_without_children';
}

it should return layered but always return layered_without_children , this means the function does not count the subcategories correctly. When i checked the Store > configuration > Catalog > Storefront > Category Flat it was enabled, then i disabled it and run indexer and cache flush, but still the same case.

| improve this question | | | | |
  • check the Anchor field for those categories. – kunj May 18 at 6:04
  • I only enabled the anchor field on parent category @kunj – jojo May 18 at 6:13
  • try to save it again from admin after disabled flat – kunj May 18 at 7:36
  • @kunj no luck, still not showing up – jojo May 18 at 8:04
0

Assuming the products show in the subcategories fine.

Is the parent of that anchor category also anchor? I havent experienced it first hand but I read that anchors must be anchors all way up or some subtle things don't quite work 100%. That could be what they mean?

I have found that data migration is magic for the most part but it can sometimes leave things in a state that isn't 100% what it would be if you did it on the new site.

Sometimes things just need to be kicked to reindex properly, sometimes there is an attribute wrong or missing. Sometimes due to subtle differences how M2 works. I had one with product migrated attributes not showing in admin grid like new attributes do.

I find that doing things in the new admin and seeing if they work is the fastest way to find what the issue is. In some cases it might require comparing rows in the database.

WARNING: if you are testing and plan to rerun migration from start you can just mess about. If you are not just testing and are going to run migration in delta phase, be careful adding/moving products and categories as it could cause clashes should they then be changed on the source later. I recommend disabling the SEO URL settings on the new site while you test, Settings -> Catalog, i.e. "Use Categories Path for Product URLs" and "Generate "category/product" URL Rewrites" while you mess about to debug stuff. That's a nightmare in delta migration.

Or make a backup of the database and revert after testing

Things to try:

  1. unanchor the category, save, reanchor, save
  2. Add a product manually to a subcategory, save reindex etc. Does it show? if yes time to compare that products data with your other products data
  3. Add a product manually to that top category, save reindex etc. Does it show?
  4. create a new fake product, add it to the subcategory, save reindex, does it show?
  5. Create a new anchor category and add a subcategory to it and put a products in the subcategory - does that work? If yes, time to compare that category's data
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.