Update is_required for Existing Attribute Code












8















I am thinking to update is_required data to "1" for existing "Region" attribute code.



select * From eav_attribute where attribute_id = '28'


However, I am wondering what is the practice here. Is it simply creating SQL statement and update that specific record in setup script fine? Or perhaps there may be a better way.










share|improve this question

























  • Which region attribute? for order or address?

    – Bijal Bhavsar
    Jan 24 '14 at 10:43











  • for order and address =)

    – Leongelis
    Jan 27 '14 at 3:24











  • ok I have already added code in below answer :)

    – Bijal Bhavsar
    Jan 28 '14 at 5:53
















8















I am thinking to update is_required data to "1" for existing "Region" attribute code.



select * From eav_attribute where attribute_id = '28'


However, I am wondering what is the practice here. Is it simply creating SQL statement and update that specific record in setup script fine? Or perhaps there may be a better way.










share|improve this question

























  • Which region attribute? for order or address?

    – Bijal Bhavsar
    Jan 24 '14 at 10:43











  • for order and address =)

    – Leongelis
    Jan 27 '14 at 3:24











  • ok I have already added code in below answer :)

    – Bijal Bhavsar
    Jan 28 '14 at 5:53














8












8








8


3






I am thinking to update is_required data to "1" for existing "Region" attribute code.



select * From eav_attribute where attribute_id = '28'


However, I am wondering what is the practice here. Is it simply creating SQL statement and update that specific record in setup script fine? Or perhaps there may be a better way.










share|improve this question
















I am thinking to update is_required data to "1" for existing "Region" attribute code.



select * From eav_attribute where attribute_id = '28'


However, I am wondering what is the practice here. Is it simply creating SQL statement and update that specific record in setup script fine? Or perhaps there may be a better way.







attributes upgrade






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 28 mins ago









Teja Bhagavan Kollepara

2,96341847




2,96341847










asked Jan 24 '14 at 10:21









LeongelisLeongelis

380721




380721













  • Which region attribute? for order or address?

    – Bijal Bhavsar
    Jan 24 '14 at 10:43











  • for order and address =)

    – Leongelis
    Jan 27 '14 at 3:24











  • ok I have already added code in below answer :)

    – Bijal Bhavsar
    Jan 28 '14 at 5:53



















  • Which region attribute? for order or address?

    – Bijal Bhavsar
    Jan 24 '14 at 10:43











  • for order and address =)

    – Leongelis
    Jan 27 '14 at 3:24











  • ok I have already added code in below answer :)

    – Bijal Bhavsar
    Jan 28 '14 at 5:53

















Which region attribute? for order or address?

– Bijal Bhavsar
Jan 24 '14 at 10:43





Which region attribute? for order or address?

– Bijal Bhavsar
Jan 24 '14 at 10:43













for order and address =)

– Leongelis
Jan 27 '14 at 3:24





for order and address =)

– Leongelis
Jan 27 '14 at 3:24













ok I have already added code in below answer :)

– Bijal Bhavsar
Jan 28 '14 at 5:53





ok I have already added code in below answer :)

– Bijal Bhavsar
Jan 28 '14 at 5:53










6 Answers
6






active

oldest

votes


















11














Create sql script to update region attribute



$installer->startSetup();
/*** Update customer address attributes*/
$installer->updateAttribute('customer_address', 'region', 'is_required', true);

/*** Update order address attributes*/
$installer->updateAttribute('order_address', 'region', 'is_required', true);
$installer->endSetup();


I hope above code will help






share|improve this answer


























  • Can you please explain it in deep with example.

    – Ami Kamboj
    Jun 20 '14 at 10:13



















4














I am writing this updates is simply sharing my research and hope could help someone out there.



config.xml



<config>
<modules>
<Package_Module>
<version>0.0.2</version>
</Package_Module>
</modules>
<global>
<resources>
<module_setup>
<setup>
<module>Package_Module</module>
<!--
Create a Switchable Installer Script
This class is incredibly handy in case you need different setup classes
-->
<class>Package_Module_Model_Resource_Setup</class>
</setup>
</module_setup>
</resources>
</global>
<config>


Custom Setup Class: Package_Module_Model_Resource_Setup



class Package_Module_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
{
public function getCatalogResourceSetup()
{
return new Mage_Catalog_Model_Resource_Setup('module_setup');
}
public function getCustomerResourceSetup()
{
return new Mage_Customer_Model_Resource_Setup('module_setup');
}
public function getCustomerEntitySetup()
{
return new Mage_Customer_Model_Entity_Setup('module_setup');
}
}


Upgrade Script: mysql4-upgrade-0.0.1-0.0.2.php



<?php
/* @var $installer Package_Module_Model_Resource_Setup */
$installer = $this->getCustomerEntitySetup();

$installer->startSetup();
/*** Update customer address attributes*/
$installer->updateAttribute('customer_address', 'region', 'is_required', 1);

$installer->endSetup();


Hereby a great article that shared about 'Switchable Installer Script'. Source link: inchoo.net






share|improve this answer































    0














    Create sql update script and run updateAttribute function.



    $installer = $this;
    $installer->startSetup();
    $installer->updateAttribute('entity_type', 'your_attribute_id', 'required', 1);
    $installer->endSetup();


    With this function you can update any attribute's property.






    share|improve this answer

































      0














      I was trying some scripts found, but the attribute still was required. The correct parameter is 'is_required' and not 'required'.

      $installer->updateAttribute('entity_type', 'your_attribute_id', 'is_required', 1);






      share|improve this answer































        0














        Below code will update attribute using sql script



        $installer = $this;
        $this->updateAttribute('customer_address', 'region', 'is_required' ,1);





        share|improve this answer































          0














          you can find definition of updateAttribute() function in file appcodecoreMageEavModelEntitysetup.php






          share|improve this answer























            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%2f13775%2fupdate-is-required-for-existing-attribute-code%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            6 Answers
            6






            active

            oldest

            votes








            6 Answers
            6






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            11














            Create sql script to update region attribute



            $installer->startSetup();
            /*** Update customer address attributes*/
            $installer->updateAttribute('customer_address', 'region', 'is_required', true);

            /*** Update order address attributes*/
            $installer->updateAttribute('order_address', 'region', 'is_required', true);
            $installer->endSetup();


            I hope above code will help






            share|improve this answer


























            • Can you please explain it in deep with example.

              – Ami Kamboj
              Jun 20 '14 at 10:13
















            11














            Create sql script to update region attribute



            $installer->startSetup();
            /*** Update customer address attributes*/
            $installer->updateAttribute('customer_address', 'region', 'is_required', true);

            /*** Update order address attributes*/
            $installer->updateAttribute('order_address', 'region', 'is_required', true);
            $installer->endSetup();


            I hope above code will help






            share|improve this answer


























            • Can you please explain it in deep with example.

              – Ami Kamboj
              Jun 20 '14 at 10:13














            11












            11








            11







            Create sql script to update region attribute



            $installer->startSetup();
            /*** Update customer address attributes*/
            $installer->updateAttribute('customer_address', 'region', 'is_required', true);

            /*** Update order address attributes*/
            $installer->updateAttribute('order_address', 'region', 'is_required', true);
            $installer->endSetup();


            I hope above code will help






            share|improve this answer















            Create sql script to update region attribute



            $installer->startSetup();
            /*** Update customer address attributes*/
            $installer->updateAttribute('customer_address', 'region', 'is_required', true);

            /*** Update order address attributes*/
            $installer->updateAttribute('order_address', 'region', 'is_required', true);
            $installer->endSetup();


            I hope above code will help







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 7 '18 at 16:04









            Michael Poppinger

            1035




            1035










            answered Jan 24 '14 at 11:01









            Bijal BhavsarBijal Bhavsar

            1,143926




            1,143926













            • Can you please explain it in deep with example.

              – Ami Kamboj
              Jun 20 '14 at 10:13



















            • Can you please explain it in deep with example.

              – Ami Kamboj
              Jun 20 '14 at 10:13

















            Can you please explain it in deep with example.

            – Ami Kamboj
            Jun 20 '14 at 10:13





            Can you please explain it in deep with example.

            – Ami Kamboj
            Jun 20 '14 at 10:13













            4














            I am writing this updates is simply sharing my research and hope could help someone out there.



            config.xml



            <config>
            <modules>
            <Package_Module>
            <version>0.0.2</version>
            </Package_Module>
            </modules>
            <global>
            <resources>
            <module_setup>
            <setup>
            <module>Package_Module</module>
            <!--
            Create a Switchable Installer Script
            This class is incredibly handy in case you need different setup classes
            -->
            <class>Package_Module_Model_Resource_Setup</class>
            </setup>
            </module_setup>
            </resources>
            </global>
            <config>


            Custom Setup Class: Package_Module_Model_Resource_Setup



            class Package_Module_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
            {
            public function getCatalogResourceSetup()
            {
            return new Mage_Catalog_Model_Resource_Setup('module_setup');
            }
            public function getCustomerResourceSetup()
            {
            return new Mage_Customer_Model_Resource_Setup('module_setup');
            }
            public function getCustomerEntitySetup()
            {
            return new Mage_Customer_Model_Entity_Setup('module_setup');
            }
            }


            Upgrade Script: mysql4-upgrade-0.0.1-0.0.2.php



            <?php
            /* @var $installer Package_Module_Model_Resource_Setup */
            $installer = $this->getCustomerEntitySetup();

            $installer->startSetup();
            /*** Update customer address attributes*/
            $installer->updateAttribute('customer_address', 'region', 'is_required', 1);

            $installer->endSetup();


            Hereby a great article that shared about 'Switchable Installer Script'. Source link: inchoo.net






            share|improve this answer




























              4














              I am writing this updates is simply sharing my research and hope could help someone out there.



              config.xml



              <config>
              <modules>
              <Package_Module>
              <version>0.0.2</version>
              </Package_Module>
              </modules>
              <global>
              <resources>
              <module_setup>
              <setup>
              <module>Package_Module</module>
              <!--
              Create a Switchable Installer Script
              This class is incredibly handy in case you need different setup classes
              -->
              <class>Package_Module_Model_Resource_Setup</class>
              </setup>
              </module_setup>
              </resources>
              </global>
              <config>


              Custom Setup Class: Package_Module_Model_Resource_Setup



              class Package_Module_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
              {
              public function getCatalogResourceSetup()
              {
              return new Mage_Catalog_Model_Resource_Setup('module_setup');
              }
              public function getCustomerResourceSetup()
              {
              return new Mage_Customer_Model_Resource_Setup('module_setup');
              }
              public function getCustomerEntitySetup()
              {
              return new Mage_Customer_Model_Entity_Setup('module_setup');
              }
              }


              Upgrade Script: mysql4-upgrade-0.0.1-0.0.2.php



              <?php
              /* @var $installer Package_Module_Model_Resource_Setup */
              $installer = $this->getCustomerEntitySetup();

              $installer->startSetup();
              /*** Update customer address attributes*/
              $installer->updateAttribute('customer_address', 'region', 'is_required', 1);

              $installer->endSetup();


              Hereby a great article that shared about 'Switchable Installer Script'. Source link: inchoo.net






              share|improve this answer


























                4












                4








                4







                I am writing this updates is simply sharing my research and hope could help someone out there.



                config.xml



                <config>
                <modules>
                <Package_Module>
                <version>0.0.2</version>
                </Package_Module>
                </modules>
                <global>
                <resources>
                <module_setup>
                <setup>
                <module>Package_Module</module>
                <!--
                Create a Switchable Installer Script
                This class is incredibly handy in case you need different setup classes
                -->
                <class>Package_Module_Model_Resource_Setup</class>
                </setup>
                </module_setup>
                </resources>
                </global>
                <config>


                Custom Setup Class: Package_Module_Model_Resource_Setup



                class Package_Module_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
                {
                public function getCatalogResourceSetup()
                {
                return new Mage_Catalog_Model_Resource_Setup('module_setup');
                }
                public function getCustomerResourceSetup()
                {
                return new Mage_Customer_Model_Resource_Setup('module_setup');
                }
                public function getCustomerEntitySetup()
                {
                return new Mage_Customer_Model_Entity_Setup('module_setup');
                }
                }


                Upgrade Script: mysql4-upgrade-0.0.1-0.0.2.php



                <?php
                /* @var $installer Package_Module_Model_Resource_Setup */
                $installer = $this->getCustomerEntitySetup();

                $installer->startSetup();
                /*** Update customer address attributes*/
                $installer->updateAttribute('customer_address', 'region', 'is_required', 1);

                $installer->endSetup();


                Hereby a great article that shared about 'Switchable Installer Script'. Source link: inchoo.net






                share|improve this answer













                I am writing this updates is simply sharing my research and hope could help someone out there.



                config.xml



                <config>
                <modules>
                <Package_Module>
                <version>0.0.2</version>
                </Package_Module>
                </modules>
                <global>
                <resources>
                <module_setup>
                <setup>
                <module>Package_Module</module>
                <!--
                Create a Switchable Installer Script
                This class is incredibly handy in case you need different setup classes
                -->
                <class>Package_Module_Model_Resource_Setup</class>
                </setup>
                </module_setup>
                </resources>
                </global>
                <config>


                Custom Setup Class: Package_Module_Model_Resource_Setup



                class Package_Module_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
                {
                public function getCatalogResourceSetup()
                {
                return new Mage_Catalog_Model_Resource_Setup('module_setup');
                }
                public function getCustomerResourceSetup()
                {
                return new Mage_Customer_Model_Resource_Setup('module_setup');
                }
                public function getCustomerEntitySetup()
                {
                return new Mage_Customer_Model_Entity_Setup('module_setup');
                }
                }


                Upgrade Script: mysql4-upgrade-0.0.1-0.0.2.php



                <?php
                /* @var $installer Package_Module_Model_Resource_Setup */
                $installer = $this->getCustomerEntitySetup();

                $installer->startSetup();
                /*** Update customer address attributes*/
                $installer->updateAttribute('customer_address', 'region', 'is_required', 1);

                $installer->endSetup();


                Hereby a great article that shared about 'Switchable Installer Script'. Source link: inchoo.net







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 26 '14 at 2:31









                LeongelisLeongelis

                380721




                380721























                    0














                    Create sql update script and run updateAttribute function.



                    $installer = $this;
                    $installer->startSetup();
                    $installer->updateAttribute('entity_type', 'your_attribute_id', 'required', 1);
                    $installer->endSetup();


                    With this function you can update any attribute's property.






                    share|improve this answer






























                      0














                      Create sql update script and run updateAttribute function.



                      $installer = $this;
                      $installer->startSetup();
                      $installer->updateAttribute('entity_type', 'your_attribute_id', 'required', 1);
                      $installer->endSetup();


                      With this function you can update any attribute's property.






                      share|improve this answer




























                        0












                        0








                        0







                        Create sql update script and run updateAttribute function.



                        $installer = $this;
                        $installer->startSetup();
                        $installer->updateAttribute('entity_type', 'your_attribute_id', 'required', 1);
                        $installer->endSetup();


                        With this function you can update any attribute's property.






                        share|improve this answer















                        Create sql update script and run updateAttribute function.



                        $installer = $this;
                        $installer->startSetup();
                        $installer->updateAttribute('entity_type', 'your_attribute_id', 'required', 1);
                        $installer->endSetup();


                        With this function you can update any attribute's property.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 24 '14 at 11:09

























                        answered Jan 24 '14 at 10:49









                        oleksii.svarychevskyioleksii.svarychevskyi

                        4,80111022




                        4,80111022























                            0














                            I was trying some scripts found, but the attribute still was required. The correct parameter is 'is_required' and not 'required'.

                            $installer->updateAttribute('entity_type', 'your_attribute_id', 'is_required', 1);






                            share|improve this answer




























                              0














                              I was trying some scripts found, but the attribute still was required. The correct parameter is 'is_required' and not 'required'.

                              $installer->updateAttribute('entity_type', 'your_attribute_id', 'is_required', 1);






                              share|improve this answer


























                                0












                                0








                                0







                                I was trying some scripts found, but the attribute still was required. The correct parameter is 'is_required' and not 'required'.

                                $installer->updateAttribute('entity_type', 'your_attribute_id', 'is_required', 1);






                                share|improve this answer













                                I was trying some scripts found, but the attribute still was required. The correct parameter is 'is_required' and not 'required'.

                                $installer->updateAttribute('entity_type', 'your_attribute_id', 'is_required', 1);







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Nov 26 '14 at 17:51









                                Antonio PediciniAntonio Pedicini

                                5981029




                                5981029























                                    0














                                    Below code will update attribute using sql script



                                    $installer = $this;
                                    $this->updateAttribute('customer_address', 'region', 'is_required' ,1);





                                    share|improve this answer




























                                      0














                                      Below code will update attribute using sql script



                                      $installer = $this;
                                      $this->updateAttribute('customer_address', 'region', 'is_required' ,1);





                                      share|improve this answer


























                                        0












                                        0








                                        0







                                        Below code will update attribute using sql script



                                        $installer = $this;
                                        $this->updateAttribute('customer_address', 'region', 'is_required' ,1);





                                        share|improve this answer













                                        Below code will update attribute using sql script



                                        $installer = $this;
                                        $this->updateAttribute('customer_address', 'region', 'is_required' ,1);






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Mar 11 '15 at 10:12









                                        DigishaDigisha

                                        1345




                                        1345























                                            0














                                            you can find definition of updateAttribute() function in file appcodecoreMageEavModelEntitysetup.php






                                            share|improve this answer




























                                              0














                                              you can find definition of updateAttribute() function in file appcodecoreMageEavModelEntitysetup.php






                                              share|improve this answer


























                                                0












                                                0








                                                0







                                                you can find definition of updateAttribute() function in file appcodecoreMageEavModelEntitysetup.php






                                                share|improve this answer













                                                you can find definition of updateAttribute() function in file appcodecoreMageEavModelEntitysetup.php







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Sep 29 '16 at 9:37









                                                AjayAjay

                                                12




                                                12






























                                                    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%2f13775%2fupdate-is-required-for-existing-attribute-code%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

                                                    What other Star Trek series did the main TNG cast show up in?

                                                    Berlina muro

                                                    Berlina aerponto