Skip to content

Multiselect filter doesn't render with a good structure #841

@Yivan

Description

@Yivan

Hello,

On the last coreshop version, multiselect filter doesn't seems to be correctly rendered for the structure of the options.

Here is a way to reproduce it:

  • on the product class, add a multiselect field named "multisection"
    multiselect-classe

  • create an index
    multiselect-index

  • create a filter
    multiselect-filter

  • create two products, one having "gamme1" and "gamme2" selected, and the other having "gamme2" and "gamme3" selected.

  • calling preparedCondition this way:

        $page = $request->get('page', 0);
        $defaultPerPage = 5;
        $perPage = $request->get('perPage', $defaultPerPage);
        
        $filter = $this->get('coreshop.repository.filter')->find(1); //Get Filter by ID 1
        $filteredList = $this->get('coreshop.factory.filter.list')->createList($filter, $request->request);
        $filteredList->setLocale($request->getLocale());
        $filteredList->setVariantMode(\CoreShop\Component\Index\Listing\ListingInterface::VARIANT_MODE_HIDE);

        $filteredList->load();
        
        $currentFilter = $this->get('coreshop.filter.processor')->processConditions($filter, $filteredList, $request->query);
        $preparedConditions = $this->get('coreshop.filter.processor')->prepareConditionsForRendering($filter, $filteredList, $currentFilter);  

A dump of $preparedConditions returns:

  1 => array:6 [▼
    "type" => "multiselect"
    "label" => "multisection"
    "currentValues" => []
    "values" => array:2 [▼
      0 => array:2 [▼
        "value" => ",gamme1,gamme2,"
        "count" => "1"
      ]
      1 => array:2 [▼
        "value" => ",gamme3,gamme2,"
        "count" => "1"
      ]
    ]
    "fieldName" => "multisection"
    "quantityUnit" => null
  ]

It should return the following values:

    "values" => array:3 [▼
      0 => array:2 [▼
        "value" => "gamme1"
        "count" => "1"
      ]
      1 => array:2 [▼
        "value" => "gamme2"
        "count" => "2"
      ]
      2 => array:2 [▼
        "value" => "gamme3"
        "count" => "1"
      ]
    ]

Here is a screenshoot of the rendering using the default twig template for multiselect:
multiselect-render

It should be 3 checkbox... "gamme1", "gamme2" and "gamme3".

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions