In version 2.0.x I was able to add another tab to the category edit page in the backend. But since Magento2 moved to UI Components with version 2.1.x it's broken. I can't get my head around it actually that's why i'm asking here.

Do I have to extend Magento\Catalog\Model\Category\DataProvider? Or is there a smarter way?

I want to add another field to the category edit page where I can access the current category product collection.

Can anyone help me out?

  • Do you want to add a new Tab or a new Field? Because a tab named Products in Category already exists and it's not quite clear what you mean by "access the current category product collection". – adjco Nov 6 '16 at 15:09
  • Well, in the code it's called field... but you are right, it's another tab in the end. sorry for the late response, didn't had much time lately. – Thomas Lindner Nov 8 '16 at 23:52

Its not as bad as it seems although not super easy either. Take a look at the.

I assume you have a module creating the new field, you need a bit more definition in order to make the field appear.

You need to add category_form.xml under view/adminhtml/ui_component and in here you define the field structure.

You still need the fields you want to use defined in the eav_attribute table, so make sure these are still present.

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="new_tab_id">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">New Tab</item>
                <item name="collapsible" xsi:type="boolean">true</item>
                <item name="sortOrder" xsi:type="number">50</item>
        <field name="new_field">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="sortOrder" xsi:type="number">10</item>
                    <item name="dataType" xsi:type="string">string</item>
                    <item name="formElement" xsi:type="string">input</item>
                    <item name="scopeLabel" xsi:type="string" translate="true">[STORE VIEW]</item>
                    <item name="label" xsi:type="string" translate="true">New field</item>
  • Thanks, Corefix. I'll test it tomorrow, didn't had much time lately, sry. Will report back! – Thomas Lindner Nov 8 '16 at 23:54
  • Ahh... category_form.xml is a ui_component definition in the module_catalog. And because i've added one to my own module it gets extended?! Good to know :) – Thomas Lindner Nov 9 '16 at 21:32
  • If we need to save that data from the inserted field. Can we save that in our custom table? If yes then how? – Zeeshan May 3 '19 at 15:38
  • How can you display field value on the front-end? – Sam Jul 14 '20 at 8:25

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.