community-features icon indicating copy to clipboard operation
community-features copied to clipboard

Visual Merchandiser should accept multi-select attributes

Open imontaine opened this issue 4 years ago • 2 comments

In Magento 1 we were able to create merchandising rules to select a value from a Multi-select attribute. But, in Magento 2 the multi-select attributes are not selectable.

It seems like Magento 2 Devs removed this feature, but I am not sure why.

Please look at the following file: vendor/magento/module-visual-merchandiser/Model/Config/Source/AllowedAttributes.php

public function toOptionArray()

{
    $entityTypeId = $this->type->loadByCode(\Magento\Catalog\Model\Product::ENTITY)->getId();
    if ($entityTypeId) {
        $collection = $this->attribute->getCollection()
            ->removeAllFieldsFromSelect()
            ->addFieldToSelect('attribute_code', 'value')
            ->addFieldToSelect('frontend_label', 'label')
            ->addFieldToFilter('entity_type_id', ['eq' => $entityTypeId])
            ->addFieldToFilter('frontend_input', ['neq' => 'multiselect']); // <------------------------------ THIS LINE
        $attributes = $collection->toArray();
        if (isset($attributes['items'])) {
            $this->options = $attributes['items'];
        }
    }
    return $this->options;
}

imontaine avatar Aug 03 '20 19:08 imontaine

Hi @imontaine. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar Aug 03 '20 19:08 m2-assistant[bot]

I would like this feature as well

hcmlopes avatar Apr 08 '21 19:04 hcmlopes