Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiselect attributes with source models in Virtual Categories #369

Closed
madonzy opened this issue Mar 23, 2017 · 2 comments
Closed

Multiselect attributes with source models in Virtual Categories #369

madonzy opened this issue Mar 23, 2017 · 2 comments

Comments

@madonzy
Copy link

madonzy commented Mar 23, 2017

Virtual categories doesn't work with products that have multiselect attribute with source model, only those with predefined values works.

Preconditions

OS: Linux debian-8 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux
Magento Version: 2.1.4 CE
ElasticSuite Version: 2.3.4
Environment: developer

Steps to reproduce

  1. In own module setup I use this configuration while adding the attribute:
[
                'type'                    => 'text',
                'backend'                 => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
                'frontend'                => '',
                'label'                   => 'Brand',
                'input'                   => 'multiselect',
                'class'                   => '',
                'source'                  => 'XXX\YYY\Model\Source\Array',
                'global'                  => ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible'                 => true,
                'required'                => false,
                'user_defined'            => true,
                'default'                 => '',
                'searchable'              => true,
                'filterable'              => true,
                'comparable'              => false,
                'visible_on_front'        => true,
                'used_in_product_listing' => true,
                'unique'                  => false,
                'apply_to'                => '',
            ]
  1. Add this attribute to default set
  2. In source model I override this method:
/**
     * {@inheritdoc}
     */
    public function getAllOptions()
    {
        if ($this->_options === null) {
            $this->_options = [
                [
                    'value' => 'nike',
                    'label' => 'Nike'
                ],
                [
                    'value' => 'adidas',
                    'label' => 'Adidas'
                ],
                [
                    'value' => 'puma',
                    'label' => 'Puma'
                ]
            ];

            // TODO: implement brand fetching
        }

        return $this->_options;
    }
  1. Set one product to value Adidas
  2. Create new virtual category with this attribute = 'Adidas'
  3. Check the front
  4. Full reindex, cahce:clean
    P.S: attribute facet coverage rate equal 1, there totally 2000 products in the store.

Expected result

  1. I can see this product on front

Actual result

  1. I can NOT see this product on front
@romainruaud
Copy link
Collaborator

Hello,

I just processed exactly the same in my testing environment.

I got no problem, the category is properly displaying the unique product.

Are you sure you did properly clean the DI after upgrading to 2.3.4 ? There was a bug related to virtual categories that could explain why you are not seeing the product in Front.

Regards,

@romainruaud
Copy link
Collaborator

This is due to your attribute being wrongly created and therefore basically a duplicate of #363, check my answer in the #363 to fix also this one.

Feel free to reopen if you are still encountering problems.

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants