- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Multiselect custom attribute module is not showing on layered navigation but shows on product edit
I'm getting a little frustrated with this, below is code i have to create a custom multi-select attribute for a product, it uses a custom source to pull the data for it from a database table, when selecting the attributes on the product edit screen it saves the id values (primary keys of the table the data comes from).
I thought that the source would also be used on the front end to create check boxes, but nothing i do makes it show up (and i have added a multi select in the admin directly and that attribute shows up just fine):
$eavSetup->addAttribute(
Product::ENTITY,
'svgs',
[
'type' => 'varchar',
'label' => 'Select SVG/Filters',
'input' => 'multiselect',
'source' => 'Vendor\Module\Model\Config\Attributes\SvgOptions',
'backend'=> 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
'required' => false,
'sort_order' => 100,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Product Overview SVG/Filters',
'visible_on_front' => true,
'used_in_product_listing' => true,
'filterable'=>true,
'searchable'=>true,
'comparable'=>false,
'user_defined'=>true,
'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
'is_used_in_grid' => true,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => true
]
);
My data source is this:
public function getAllOptions() : array
{
/** @var Collection $svgCollection */
$svgCollection = $this->svgCollectionFactory->create();
/** @var Collection $svgCategoryCollection */
$svgCategoryCollection = $this->svgCategoryCollectionFactory->create();
// get all categories
$categories = $svgCategoryCollection->setOrder('name','ASC');
// for each category as an option group, assign SVGs
$options = [];
/** @var Category $category */
foreach($categories as $category) {
// reset where in collection so each loop works
$svgCollection->clear()->getSelect()->reset('where');
// get svgs in this category
$svgs = $svgCollection->addFieldToFilter('category_id',$category->getId())
->setOrder('display_name','ASC');
if($svgs->count() > 0){
// create svgs array
$svgOptions = [];
/** @var SVG $svg */
foreach ($svgs as $svg) {
$svgOptions[] = [
'label'=>$svg->getData('display_name'),
'value'=>$svg->getId()
];
}
// add category with svgs to options
$options[] = [
'label'=>$category->getData('name'),
'value'=>$svgOptions
];
}
}
return $options;
}
All the options show in the admin and save no problem, it's just the layered nav they won't show up on
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Multiselect custom attribute module is not showing on layered navigation but shows on product ed
Hello @marcintota03e5
There are a couple of options
Use In Layered Navigation
Use In Search Results Layered Navigation
Make sure they are enabled.
Also try Filterable (no results) Will have to index after changing settings
Also double check attribute values are saved for the product under the store scope you are using.
If you are using only one store toggle single store mode if you are not using that already. That simplifies things.
Changing the backend_type of the attribute from 'text' to 'varchar' and re-index.
Don't forget to copy catalog_product_entity_text's value over to catalog_producut_entity_varchar.
Hope it helps !
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Multiselect custom attribute module is not showing on layered navigation but shows on product ed
Multiselect Custom Attribute Not Showing in Layered Navigation – A Frustrating Magento 2 Issue
I can understand the frustration here! It looks like your custom multiselect attribute is functioning properly in the admin panel but not appearing in layered navigation on the frontend. Since you’ve set 'filterable' => true, one possible issue could be missing configuration under Stores > Attributes > Product—you may need to ensure the attribute is set as "Filterable (with results)."
Additionally, Magento's layered navigation works best with "dropdown" or "multiselect" attributes of type 'int' instead of 'varchar'. Since you are storing ID values, you might want to check if changing 'type' => 'varchar' to 'type' => 'int' resolves the issue. Also, confirm that indexing and caching are properly refreshed.
This situation reminds me of why many users seek alternative solutions like Honista https://honistadownloadapk.com/ APK —when native configurations fail to provide expected flexibility, third-party tools and custom modifications often become the go-to option. While Magento 2 is powerful, sometimes even simple configurations can be a struggle without deeper custom tweaks. Hopefully, Magento improves its built-in attribute handling to make such setups more intuitive!
Would love to hear if you find a fix—best of luck debugging!