CMS Magento Mastering Development

Custom category attribute is not being saved – issue

I managed to create my custom attribute:

    $installer = $setup;
    $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);

            'type' => 'int',
            'label' => 'Content Page',
            'input' => 'select',
            'sort_order' => 100,
            'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Page',
            'global' => 2,
            'visible' => true,
            'required' => true,
            'user_defined' => false,
            'default' => null,
            'group' => 'General Information',
            'backend' => ''

I made the file view/adminhtml/ui_component/category_form.xml with this content:

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="content">
        <field name="content_category_page">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">Vendor\Module\Model\Config\ContentPages</item>
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Content Page</item>
                    <item name="formElement" xsi:type="string">select</item>
                    <item name="dataScope" xsi:type="string">content_category_page</item>

The new attribute appeared in the right place, but when i choose an option and press the save button, the value is not being saved . Would you please advice, why my custom category attribute is not created ? 🙂 Thnx in advance!

Leave a Reply

Your email address will not be published. Required fields are marked *