heimrichhannot / contao-categories-bundle

This bundle allows to assign nestable categories to arbitrary entities in Contao-driven systems.
4 stars 2 forks source link

The filter menu shows only the categories in 1st level, not the subcategories. #13

Open arboc opened 3 years ago

arboc commented 3 years ago

Context Contao version: 4.9.12
Bundle version: 1.1.1 PHP version: 7.4

Description This is an issue in combination with the heimrichhannot/contao-categories-multilingual-bundle version 0.0.4 and refers to the frontend module: filter menu.

With the default language, every things works. But with a second language I have the following problems:

The filter menu shows only the categories in 1st level, not the subcategories.

koertho commented 3 years ago

@Defcon0 Do you have an idea here?

arboc commented 3 years ago

I think, it is somewhere here:

line 106 in HeimrichHannot\CategoriesBundle\Module\ModuleCategoriesMenu

        // Get the parent categories IDs
        foreach ($categories as $category) {
            if ($this->cm_customCategories) {
                $arrIds[] = $category->id;
            } else {
                $arrIds = array_merge($arrIds, $categoriesManager->findBy('pid', $category->pid)->fetchEach('id'));
            }
        }

The problem is, the pid of a category entity wich belongs to a language refers to the entity of the default language and not the hierachical parent. So the $arrIds will be wrong.

something like this might help:

if (isset($category->language ) && ('' != $category->language ) {
    $category = CategoryModel::findById($category->pid);
}
Defcon0 commented 3 years ago

Could you write a PR for that one?

arboc commented 3 years ago

my idea does not work...