Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento adding attribute with option filterable (no results) through extension installation

I've searched around quite a bit for this answer and haven't been able to trace down the exact setting I need. I'm reaching out to see if anyone can help.

I'm writing a Magento extension to add some attributes to my installation. Everything is fine with the exception of one intricacy. I cannot set the attribute's "Use In Layered Navigation" property to "Filterable (no results)".

I can use the values in the attribute array in my installer file (below) to set that property to either "No" (0 value) or "Filterable (with results)" (1 value) but not without results.

Anyone have a suggestion of a property I may be missing or set incorrectly in my array?

Very much appreciated!

<?php
...

    // Add the mm_framestyle attr. (filterable, non-super attr.)
$setup->addAttribute('catalog_product', 'mm_framestyle', array(
             'backend'           => 'eav/entity_attribute_backend_array',
             'visible'           => true,
             'required'          => false,
             'user_defined'      => true,
             'searchable'        => true,
             'filterable'        => true,
             'comparable'        => true,
             'label'             => 'Frame Types',
             'group'             => 'MyMaui Attributes',
             'type'              => 'varchar',
             'input'             => 'select',
             'global'            => false,
             'option'            => array (
                                            'value' => array('maui_flex' => array('MAUI FLEX'),
                                                             'full_frame_metal' => array('FULL FRAME'),
                                                             'rimless_metal' => array('RIMLESS'),
                                                             'shields' => array('SHIELDS'),
                                                             )
                                        ),
             'visible_on_front'  => true,
             'unique'            => false
));

...
?>
like image 843
Brian F Avatar asked Nov 29 '11 15:11

Brian F


People also ask

What are Extension attributes in Magento 2?

Extension attributes are new in Magento 2. They are used to extend functionality and often use more complex data types than custom attributes. These attributes do not appear in the Admin.


1 Answers

To set the is_filterable property to "Filterable (no results)", your configuration array should have filterable set to 2.

If you wish to use an update script to change the previously-established setting, the syntax would be as follows:

$setup->updateAttribute('catalog_product', 'mm_framestyle', 'is_filterable', 2);
like image 132
benmarks Avatar answered Sep 25 '22 15:09

benmarks