I created a custom category multiselect attribute. (it's even a custom source but that does not matter).

Everything is OK on save, admin forms OK, even the flat contains my values. ( thx to https://github.com/magento/magento2/issues/417 )

BUT, when i do a list/get on front through repository, my category object does not have the values... (flat is activated)

I found an event in \Magento\Catalog\Model\ResourceModel\Category\Flat

// Allow extensions to modify select (e.g. add custom category attributes to select)
$this->_eventManager->dispatch('catalog_category_flat_loadnodes_before', ['select' => $select]);
  • Is that the only way ? It seems weird to me when i think about the XML of Magento 1.
  • Do i have to modify anything else ?

edit: Even with flat disabled, i can't get it...

edit2: ok, i'm stupid. A part of the problem was because i was in \Magento\Catalog\Helper\Category function canShow , and it uses a "hard coded" collection through the getCategoryTree function . Hooray, another plugin to write. The funny thing is that i know have a string instead of an array through get. As if the afterLoad was not called... Another mystery...

But then... the observer i gave. What is its purpose ?

1 Answer 1


Doing a search for the event name revealed that it isn't actually used anywhere in the system. So, the best guess I have is what I can ascertain from the comment: the core team wants to expose a way to add custom attributes to the select.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.