Category attribute is not being savedShow WYSIWYG button below custom category attributeHow can i rewrite...

How do I draw the dashed lines as shown in this figure

Constexpr if with a non-bool condition

Would tunnel walls be stronger if built using cut granite block walls reinforced with carbon based cords?

How do you funnel food off a cutting board?

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

Python Pandas - difference between 'loc' and 'where'?

How does Leonard in "Memento" remember reading and writing?

With regard to distributive law of inner product in vector algebra

Play Zip, Zap, Zop

After checking in online, how do I know whether I need to go show my passport at airport check-in?

Am I a Rude Number?

Clues on how to solve these types of problems within 2-3 minutes for competitive exams

A Missing Symbol for This Logo

Why is Agricola named as such?

It took me a lot of time to make this, pls like. (YouTube Comments #1)

Line of Bones to Travel and Conform to Curve (Like Train on a Track...)

Why didn't Tom Riddle take the presence of Fawkes and the Sorting Hat as more of a threat?

Is a new boolean field better than null reference when a value can be meaningfully absent?

How would an AI self awareness kill switch work?

Does Skippy chunky peanut butter contain trans fat?

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

How to use Mathematica to do a complex integrate with poles in real axis?

How to make ice magic work from a scientific point of view?

Why was Lupin comfortable with saying Voldemort's name?



Category attribute is not being saved


Show WYSIWYG button below custom category attributeHow can i rewrite TierPrice Block in Magento2create custom attribute for root category in adminError Add Result page breadcrumbGet custom category attribute in block TopmenuMagento 2 Fatal error after saved Category Custom Image AttributeAdd an extension to edit the product name quickly in admin. Magento 2Magento2 Unable to save custom category attributeCustomer account creation, save boolean value in attributeHow to Update Magento 2 configurable child products price by REST API













0















I have two custom attributes for categories. The code for both is similar apart from the attribute_code but one is not being saved when trying to add a value in adminhtml.



That's the UpgradeData.php where I add the attribute that's not saved:



$eavSetup->addAttribute(Category::ENTITY, 'megamenu_side_block', [
'type' => 'text',
'input' => 'textarea',
'label' => 'Menu Side Block',
'required' => 0,
'user_defined' => 1,
'wysiwyg_enabled' => 1,
'is_html_allowed_on_front' => 1,
'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
]);


That's the part of category_form.xml where I create the adminhtml field:



<field name="megamenu_side_block" template="ui/form/field" sortOrder="51" formElement="wysiwyg">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="wysiwygConfigData" xsi:type="array">
<item name="settings" xsi:type="array">
<item name="theme_advanced_buttons1" xsi:type="string">bold,italic,|,justifyleft,justifycenter,justifyright,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code
</item>
<item name="theme_advanced_buttons2" xsi:type="boolean">false</item>
<item name="theme_advanced_buttons3" xsi:type="boolean">false</item>
<item name="theme_advanced_buttons4" xsi:type="boolean">false</item>
<item name="theme_advanced_statusbar_location" xsi:type="boolean">false</item>
</item>
<item name="files_browser_window_url" xsi:type="boolean">false</item>
<item name="height" xsi:type="string">250px</item>
<item name="toggle_button" xsi:type="boolean">true</item>
<item name="add_variables" xsi:type="boolean">false</item>
<item name="add_widgets" xsi:type="boolean">false</item>
<item name="add_images" xsi:type="boolean">false</item>
<item name="add_directives" xsi:type="boolean">false</item>
</item>
<item name="label" xsi:type="string" translate="true">Megamenu Side Block</item>
<item name="source" xsi:type="string">category</item>
<item name="template" xsi:type="string">ui/form/field</item>
<item name="wysiwyg" xsi:type="boolean">true</item>
<item name="dataScope" xsi:type="string">megamenu_side_block</item>
<item name="rows" xsi:type="number">8</item>
</item>
</argument>
</field>


What I already checked:




  • The attribute is added to the table eav_attribute

  • When I debug into MagentoCatalogControllerAdminhtmlCategorySave::execute() the value is there and after $category->save() I can still get the value with
    $category->getMegamenuSideBlock()

  • I tried to add a value manually but it didn't work either it wasn't loaded in backend

  • When I change dataScope in xml to the attribute_code that is working the other attribute value is loaded just fine


As I said before I have a second attribute that uses the same code as above (just with different attribute_code) and that is working perfectly fine.



I've already checked several posts here but I didn't see any difference to my code or it didn't work.



What could be the reason that it's not saved to the database? Am I missing something in my code?









share



























    0















    I have two custom attributes for categories. The code for both is similar apart from the attribute_code but one is not being saved when trying to add a value in adminhtml.



    That's the UpgradeData.php where I add the attribute that's not saved:



    $eavSetup->addAttribute(Category::ENTITY, 'megamenu_side_block', [
    'type' => 'text',
    'input' => 'textarea',
    'label' => 'Menu Side Block',
    'required' => 0,
    'user_defined' => 1,
    'wysiwyg_enabled' => 1,
    'is_html_allowed_on_front' => 1,
    'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
    ]);


    That's the part of category_form.xml where I create the adminhtml field:



    <field name="megamenu_side_block" template="ui/form/field" sortOrder="51" formElement="wysiwyg">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="wysiwygConfigData" xsi:type="array">
    <item name="settings" xsi:type="array">
    <item name="theme_advanced_buttons1" xsi:type="string">bold,italic,|,justifyleft,justifycenter,justifyright,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code
    </item>
    <item name="theme_advanced_buttons2" xsi:type="boolean">false</item>
    <item name="theme_advanced_buttons3" xsi:type="boolean">false</item>
    <item name="theme_advanced_buttons4" xsi:type="boolean">false</item>
    <item name="theme_advanced_statusbar_location" xsi:type="boolean">false</item>
    </item>
    <item name="files_browser_window_url" xsi:type="boolean">false</item>
    <item name="height" xsi:type="string">250px</item>
    <item name="toggle_button" xsi:type="boolean">true</item>
    <item name="add_variables" xsi:type="boolean">false</item>
    <item name="add_widgets" xsi:type="boolean">false</item>
    <item name="add_images" xsi:type="boolean">false</item>
    <item name="add_directives" xsi:type="boolean">false</item>
    </item>
    <item name="label" xsi:type="string" translate="true">Megamenu Side Block</item>
    <item name="source" xsi:type="string">category</item>
    <item name="template" xsi:type="string">ui/form/field</item>
    <item name="wysiwyg" xsi:type="boolean">true</item>
    <item name="dataScope" xsi:type="string">megamenu_side_block</item>
    <item name="rows" xsi:type="number">8</item>
    </item>
    </argument>
    </field>


    What I already checked:




    • The attribute is added to the table eav_attribute

    • When I debug into MagentoCatalogControllerAdminhtmlCategorySave::execute() the value is there and after $category->save() I can still get the value with
      $category->getMegamenuSideBlock()

    • I tried to add a value manually but it didn't work either it wasn't loaded in backend

    • When I change dataScope in xml to the attribute_code that is working the other attribute value is loaded just fine


    As I said before I have a second attribute that uses the same code as above (just with different attribute_code) and that is working perfectly fine.



    I've already checked several posts here but I didn't see any difference to my code or it didn't work.



    What could be the reason that it's not saved to the database? Am I missing something in my code?









    share

























      0












      0








      0








      I have two custom attributes for categories. The code for both is similar apart from the attribute_code but one is not being saved when trying to add a value in adminhtml.



      That's the UpgradeData.php where I add the attribute that's not saved:



      $eavSetup->addAttribute(Category::ENTITY, 'megamenu_side_block', [
      'type' => 'text',
      'input' => 'textarea',
      'label' => 'Menu Side Block',
      'required' => 0,
      'user_defined' => 1,
      'wysiwyg_enabled' => 1,
      'is_html_allowed_on_front' => 1,
      'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
      ]);


      That's the part of category_form.xml where I create the adminhtml field:



      <field name="megamenu_side_block" template="ui/form/field" sortOrder="51" formElement="wysiwyg">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="wysiwygConfigData" xsi:type="array">
      <item name="settings" xsi:type="array">
      <item name="theme_advanced_buttons1" xsi:type="string">bold,italic,|,justifyleft,justifycenter,justifyright,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code
      </item>
      <item name="theme_advanced_buttons2" xsi:type="boolean">false</item>
      <item name="theme_advanced_buttons3" xsi:type="boolean">false</item>
      <item name="theme_advanced_buttons4" xsi:type="boolean">false</item>
      <item name="theme_advanced_statusbar_location" xsi:type="boolean">false</item>
      </item>
      <item name="files_browser_window_url" xsi:type="boolean">false</item>
      <item name="height" xsi:type="string">250px</item>
      <item name="toggle_button" xsi:type="boolean">true</item>
      <item name="add_variables" xsi:type="boolean">false</item>
      <item name="add_widgets" xsi:type="boolean">false</item>
      <item name="add_images" xsi:type="boolean">false</item>
      <item name="add_directives" xsi:type="boolean">false</item>
      </item>
      <item name="label" xsi:type="string" translate="true">Megamenu Side Block</item>
      <item name="source" xsi:type="string">category</item>
      <item name="template" xsi:type="string">ui/form/field</item>
      <item name="wysiwyg" xsi:type="boolean">true</item>
      <item name="dataScope" xsi:type="string">megamenu_side_block</item>
      <item name="rows" xsi:type="number">8</item>
      </item>
      </argument>
      </field>


      What I already checked:




      • The attribute is added to the table eav_attribute

      • When I debug into MagentoCatalogControllerAdminhtmlCategorySave::execute() the value is there and after $category->save() I can still get the value with
        $category->getMegamenuSideBlock()

      • I tried to add a value manually but it didn't work either it wasn't loaded in backend

      • When I change dataScope in xml to the attribute_code that is working the other attribute value is loaded just fine


      As I said before I have a second attribute that uses the same code as above (just with different attribute_code) and that is working perfectly fine.



      I've already checked several posts here but I didn't see any difference to my code or it didn't work.



      What could be the reason that it's not saved to the database? Am I missing something in my code?









      share














      I have two custom attributes for categories. The code for both is similar apart from the attribute_code but one is not being saved when trying to add a value in adminhtml.



      That's the UpgradeData.php where I add the attribute that's not saved:



      $eavSetup->addAttribute(Category::ENTITY, 'megamenu_side_block', [
      'type' => 'text',
      'input' => 'textarea',
      'label' => 'Menu Side Block',
      'required' => 0,
      'user_defined' => 1,
      'wysiwyg_enabled' => 1,
      'is_html_allowed_on_front' => 1,
      'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
      ]);


      That's the part of category_form.xml where I create the adminhtml field:



      <field name="megamenu_side_block" template="ui/form/field" sortOrder="51" formElement="wysiwyg">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="wysiwygConfigData" xsi:type="array">
      <item name="settings" xsi:type="array">
      <item name="theme_advanced_buttons1" xsi:type="string">bold,italic,|,justifyleft,justifycenter,justifyright,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code
      </item>
      <item name="theme_advanced_buttons2" xsi:type="boolean">false</item>
      <item name="theme_advanced_buttons3" xsi:type="boolean">false</item>
      <item name="theme_advanced_buttons4" xsi:type="boolean">false</item>
      <item name="theme_advanced_statusbar_location" xsi:type="boolean">false</item>
      </item>
      <item name="files_browser_window_url" xsi:type="boolean">false</item>
      <item name="height" xsi:type="string">250px</item>
      <item name="toggle_button" xsi:type="boolean">true</item>
      <item name="add_variables" xsi:type="boolean">false</item>
      <item name="add_widgets" xsi:type="boolean">false</item>
      <item name="add_images" xsi:type="boolean">false</item>
      <item name="add_directives" xsi:type="boolean">false</item>
      </item>
      <item name="label" xsi:type="string" translate="true">Megamenu Side Block</item>
      <item name="source" xsi:type="string">category</item>
      <item name="template" xsi:type="string">ui/form/field</item>
      <item name="wysiwyg" xsi:type="boolean">true</item>
      <item name="dataScope" xsi:type="string">megamenu_side_block</item>
      <item name="rows" xsi:type="number">8</item>
      </item>
      </argument>
      </field>


      What I already checked:




      • The attribute is added to the table eav_attribute

      • When I debug into MagentoCatalogControllerAdminhtmlCategorySave::execute() the value is there and after $category->save() I can still get the value with
        $category->getMegamenuSideBlock()

      • I tried to add a value manually but it didn't work either it wasn't loaded in backend

      • When I change dataScope in xml to the attribute_code that is working the other attribute value is loaded just fine


      As I said before I have a second attribute that uses the same code as above (just with different attribute_code) and that is working perfectly fine.



      I've already checked several posts here but I didn't see any difference to my code or it didn't work.



      What could be the reason that it's not saved to the database? Am I missing something in my code?







      magento2 magento2.2.6 category-attribute





      share












      share










      share



      share










      asked 4 mins ago









      DanielDaniel

      87211




      87211






















          1 Answer
          1






          active

          oldest

          votes


















          0















          Use functions like below




           public function beforeSave($object)
          {
          $attributeName = $this->getAttribute()->getName();
          $value = $object->getData($attributeName);

          if ($imageName = $this->getUploadedImageName($value)) {
          $object->setData($this->additionalData . $attributeName, $value);
          $object->setData($attributeName, $imageName);
          } elseif (is_string($value)) {
          $object->setData($attributeName, null);
          }
          return parent::beforeSave($object);
          }



          public function afterSave($object)
          {
          $value = $object->getData($this->additionalData . $this->getAttribute()->getName());

          --Write your code--
          return $this;
          }




          share








          New contributor




          Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "479"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263713%2fcategory-attribute-is-not-being-saved%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0















            Use functions like below




             public function beforeSave($object)
            {
            $attributeName = $this->getAttribute()->getName();
            $value = $object->getData($attributeName);

            if ($imageName = $this->getUploadedImageName($value)) {
            $object->setData($this->additionalData . $attributeName, $value);
            $object->setData($attributeName, $imageName);
            } elseif (is_string($value)) {
            $object->setData($attributeName, null);
            }
            return parent::beforeSave($object);
            }



            public function afterSave($object)
            {
            $value = $object->getData($this->additionalData . $this->getAttribute()->getName());

            --Write your code--
            return $this;
            }




            share








            New contributor




            Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

























              0















              Use functions like below




               public function beforeSave($object)
              {
              $attributeName = $this->getAttribute()->getName();
              $value = $object->getData($attributeName);

              if ($imageName = $this->getUploadedImageName($value)) {
              $object->setData($this->additionalData . $attributeName, $value);
              $object->setData($attributeName, $imageName);
              } elseif (is_string($value)) {
              $object->setData($attributeName, null);
              }
              return parent::beforeSave($object);
              }



              public function afterSave($object)
              {
              $value = $object->getData($this->additionalData . $this->getAttribute()->getName());

              --Write your code--
              return $this;
              }




              share








              New contributor




              Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.























                0












                0








                0








                Use functions like below




                 public function beforeSave($object)
                {
                $attributeName = $this->getAttribute()->getName();
                $value = $object->getData($attributeName);

                if ($imageName = $this->getUploadedImageName($value)) {
                $object->setData($this->additionalData . $attributeName, $value);
                $object->setData($attributeName, $imageName);
                } elseif (is_string($value)) {
                $object->setData($attributeName, null);
                }
                return parent::beforeSave($object);
                }



                public function afterSave($object)
                {
                $value = $object->getData($this->additionalData . $this->getAttribute()->getName());

                --Write your code--
                return $this;
                }




                share








                New contributor




                Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.











                Use functions like below




                 public function beforeSave($object)
                {
                $attributeName = $this->getAttribute()->getName();
                $value = $object->getData($attributeName);

                if ($imageName = $this->getUploadedImageName($value)) {
                $object->setData($this->additionalData . $attributeName, $value);
                $object->setData($attributeName, $imageName);
                } elseif (is_string($value)) {
                $object->setData($attributeName, null);
                }
                return parent::beforeSave($object);
                }



                public function afterSave($object)
                {
                $value = $object->getData($this->additionalData . $this->getAttribute()->getName());

                --Write your code--
                return $this;
                }





                share








                New contributor




                Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.








                share


                share






                New contributor




                Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 1 min ago









                Mitrajsinh vaghelaMitrajsinh vaghela

                361




                361




                New contributor




                Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Mitrajsinh vaghela is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263713%2fcategory-attribute-is-not-being-saved%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

                    How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

                    夢乃愛華...