Magento 2 introduced the concept of UI elements which are extensively used in the admin. The grids are ones of those and have a great new feature: bookmarks. Bookmarking is the ability to save the current configuration of a grid (filters, columns order, ...) in order to retrieve this configuration when you log back in or when you select it from the "view" dropdown in the grid header. But, while developing, you may make mistakes that will break the grid and display a "Attention Something went wrong" modal box.
TL;DR
Go to your database, find the ui_bookmark
table and remove the line where namespace
matches the grid your having troubles with and where identifier
is current
.
Debugging example for the filters in the products list
Filters for the admin products list is defined in Magento/Catalog/view/adminhtml/ui_component/product_listing.xml
, the <filters name="listing_filters">
node. This node has a child named <item name="storageConfig" xsi:type="array">
which declares how the filters configuration persistence is managed:
- the
<item name="provider"... >
node tells Magento where to find the persisted configuration. The persisted configuration is a JSON object. - the
<item name="namespace"... >
node tells Magento the path where is stored the configuration in the persistence provider.
In human words, this means: "the configuration of the filters is stored in the .current.filters
"object" of the product_listing.product_listing.listing_top.bookmarks
persistence JSON.
Let's now find the product_listing.product_listing.listing_top.bookmarks
persistence! This product_listing.product_listing.listing_top.bookmarks
is nothing more than a path matching to an XML path:
- the
product_listing.product_listing
part targets the UI component with this name. SeeMagento/Catalog/view/adminhtml/layout/catalog_product_index.xml
where there is this UI component declaration:<uiComponent name="product_listing"/>
. The reason whyproduct_listing
is repeated in theproduct_listing.product_listing
part is still unclear... - then the
listing_top.bookmarks
is easier. Just understanding it like each of the "objects" of this dotted expression is a node in theproduct_listing.xml
file with the correspondingname
attribute : listing_top
matches<container name="listing_top">
bookmarks
matches<bookmark name="bookmarks">
Once you found the <bookmark name="bookmarks">
node, you can find its child <item name="namespace" xsi:type="string">product_listing</item>
. And the namespace here is what is found in the namespace
column of the ui_bookmark
table.
So, at the end of the day: when you have the "Attention Something went wrong" modal box, try to find the corresponding bookmark and have a look in your DB! When you edit the config
column, you will find the persistence JSON object. And, when there are active filters, you will also find JSON data that, when parsed as a JS object points to... current.filters
as stated in the <item name="namespace" xsi:type="string">current.filters</item>
node of product_listing.xml
.