How to create an attribute in Magento 1.9?Sorting of Categories based on a attribute of product itemWhy is Magento Creating Files with 666 Permissions?create custom attribute for root category in adminCant's add custom product attribute for sortingurl rewrite changing automatically, how to permanently fix this?Options values of attribute “visibility”Magento 1.9.x show, value cart rules in products pageRemove attribute from entityMagento / CSV import - products aren't visible in shopCustom Attribute with custom Source is not appearing in Layered Navigation Magento1

Does academia have a lazy work culture?

Does the Intel 8086 CPU have user mode and kernel mode?

Why was Sauron not trying to find the Ring, and instead of preparing for war?

Do the licences permit GPL- and BSD-licensed applications to be used for government work?

Are there any examples of technologies have been lost over time?

Memory capability and powers of 2

What does "see" in "the Holy See" mean?

Explanation for a joke about a three-legged dog that walks into a bar

Trapped in an ocean Temple in Minecraft?

Why is a dedicated QA team member necessary?

Are the Cavalier's uses of Unwavering Mark or uses of the bonus attack granted limited per long rest?

What is the lowest-speed bogey a jet fighter can intercept/escort?

How to judge a Ph.D. applicant that arrives "out of thin air"

How do I stop my characters falling in love?

What do I do when a student working in my lab "ghosts" me?

High income, sudden windfall

How do campaign rallies gain candidates votes?

Is it normal practice to screen share with a client?

How do I run a game when my PCs have different approaches to combat?

Can I go to the UK from the Schengen on train?

Why can't my huge trees be chopped down?

How to write a sincerely religious protagonist without preaching or affirming or judging their worldview?

This message is flooding my syslog, how to find where it comes from?

What is the meaning of "you has the wind of me"?



How to create an attribute in Magento 1.9?


Sorting of Categories based on a attribute of product itemWhy is Magento Creating Files with 666 Permissions?create custom attribute for root category in adminCant's add custom product attribute for sortingurl rewrite changing automatically, how to permanently fix this?Options values of attribute “visibility”Magento 1.9.x show, value cart rules in products pageRemove attribute from entityMagento / CSV import - products aren't visible in shopCustom Attribute with custom Source is not appearing in Layered Navigation Magento1






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am new to Magento and I am creating a product attribute but the problem I have is that I have 3 Attribute Sets (default, Imported, Local), but when I create the attribute, this attribute is created in the 3 Attribute Sets, even if I do not have the created group, the attribute creates it automatically.



$this->startSetup(); 
$this->addAttribute('catalog_product', 'cod_import', array(
'label' => 'Código de Importación',
'attribute_set' => 'Importados',
'group' => 'Especificaciones de importacion',
'type' => 'decimal',
'visible' => true,
'required' => true,
"nullable" => true,
'sort_order' => 2
));
$this->endSetup();









share|improve this question




























    0















    I am new to Magento and I am creating a product attribute but the problem I have is that I have 3 Attribute Sets (default, Imported, Local), but when I create the attribute, this attribute is created in the 3 Attribute Sets, even if I do not have the created group, the attribute creates it automatically.



    $this->startSetup(); 
    $this->addAttribute('catalog_product', 'cod_import', array(
    'label' => 'Código de Importación',
    'attribute_set' => 'Importados',
    'group' => 'Especificaciones de importacion',
    'type' => 'decimal',
    'visible' => true,
    'required' => true,
    "nullable" => true,
    'sort_order' => 2
    ));
    $this->endSetup();









    share|improve this question
























      0












      0








      0








      I am new to Magento and I am creating a product attribute but the problem I have is that I have 3 Attribute Sets (default, Imported, Local), but when I create the attribute, this attribute is created in the 3 Attribute Sets, even if I do not have the created group, the attribute creates it automatically.



      $this->startSetup(); 
      $this->addAttribute('catalog_product', 'cod_import', array(
      'label' => 'Código de Importación',
      'attribute_set' => 'Importados',
      'group' => 'Especificaciones de importacion',
      'type' => 'decimal',
      'visible' => true,
      'required' => true,
      "nullable" => true,
      'sort_order' => 2
      ));
      $this->endSetup();









      share|improve this question














      I am new to Magento and I am creating a product attribute but the problem I have is that I have 3 Attribute Sets (default, Imported, Local), but when I create the attribute, this attribute is created in the 3 Attribute Sets, even if I do not have the created group, the attribute creates it automatically.



      $this->startSetup(); 
      $this->addAttribute('catalog_product', 'cod_import', array(
      'label' => 'Código de Importación',
      'attribute_set' => 'Importados',
      'group' => 'Especificaciones de importacion',
      'type' => 'decimal',
      'visible' => true,
      'required' => true,
      "nullable" => true,
      'sort_order' => 2
      ));
      $this->endSetup();






      magento-1.9 php magento1.9.2.4






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 16 at 17:57









      AndrésAndrés

      101




      101




















          2 Answers
          2






          active

          oldest

          votes


















          0














          You cannot define the attribute set when creating the attribute with this method. Change group to undefined and set user_defined as true to create an attribute without setting an attribute set. After creating it, add the attribute to an attribute set in the upgrade or setup script.






          share|improve this answer






























            0














            You can do it as part of install script




            /**
            * Add blank attibute set
            */
            $attibuteSet = new Mage_Eav_Model_Entity_Setup('core_setup');
            /* @var $attibuteSet Mage_Eav_Model_Entity_Setup */
            $attibuteSet->startSetup();
            $attibuteSet->addAttributeSet(
            Mage_Catalog_Model_Product::ENTITY, 'Custom'
            );
            $attibuteSet->endSetup();


            /**
            * Add attibute set based on default set
            */
            $attibuteSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
            $attibuteSet->startSetup();
            $defaultAttributeSetId = $attibuteSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Default');
            $entityTypeId = $attibuteSet->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
            $attributeSetsName = array('CustomTwo');


            foreach ($attributeSetsName as $attributeSetName)

            $model = Mage::getModel('eav/entity_attribute_set')->setEntityTypeId($entityTypeId);
            $model->setAttributeSetName($attributeSetName);


            try
            if ($model->validate())
            $model->save();
            $model->initFromSkeleton($defaultAttributeSetId);
            $model->save();

            catch (Exception $e)
            Mage::logException($e);


            $attibuteSet->endSetup();


            /**
            * Add Attibute
            */
            $addAttribute = new Mage_Catalog_Model_Resource_Setup('core_setup');
            /* @var $attribute Mage_Catalog_Model_Resource_Setup */
            $productTypes = array(
            Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
            Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
            );


            $addAttribute->startSetup();


            if (!$addAttribute->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute'))
            $addAttribute->addAttribute(
            Mage_Catalog_Model_Product::ENTITY,
            'custom_attribute',
            array( // TABLE.COLUMN: DESCRIPTION:
            'label' => 'Custom Attribute', // eav_attribute.frontend_label admin input label
            'group' => 'General', // (not a column) tab in product edit screen
            'sort_order' => 0, // eav_entity_attribute.sort_order sort order in group
            'backend' => '', // eav_attribute.backend_model backend class (module/class_name format)
            'type' => 'varchar', // eav_attribute.backend_type backend storage type (varchar, text etc)
            'frontend' => '', // eav_attribute.frontend_model admin class (module/class_name format)
            'note' => null, // eav_attribute.note admin input note (shows below input)
            'default' => null, // eav_attribute.default_value admin input default value
            'wysiwyg_enabled' => false, // catalog_eav_attribute.is_wysiwyg_enabled (products only) admin input wysiwyg enabled
            'input' => 'text', // eav_attribute.frontend_input admin input type (select, text, textarea etc)
            'input_renderer' => false, // catalog_eav_attribute.frontend_input_renderer (products only) admin input renderer (otherwise input is used to resolve renderer)
            'source' => null, // eav_attribute.source_model admin input source model (for selects) (module/class_name format)
            'required' => false, // eav_attribute.is_required required in admin
            'user_defined' => true, // eav_attribute.is_user_defined editable in admin attributes section, false for not
            'unique' => false, // eav_attribute.is_unique unique value required
            'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // catalog_eav_attribute.is_global (products only) scope
            'visible' => true, // catalog_eav_attribute.is_visible (products only) visible on admin
            'visible_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) visible on frontend (store) attribute table
            'used_in_product_listing' => false, // catalog_eav_attribute.used_in_product_listing (products only) made available in product listing
            'searchable' => false, // catalog_eav_attribute.is_searchable (products only) searchable via basic search
            'visible_in_advanced_search' => false, // catalog_eav_attribute.is_visible_in_advanced_search (products only) searchable via advanced search
            'filterable' => false, // catalog_eav_attribute.is_filterable (products only) use in layered nav
            'filterable_in_search' => false, // catalog_eav_attribute.is_filterable_in_search (products only) use in search results layered nav
            'comparable' => false, // catalog_eav_attribute.is_comparable (products only) comparable on frontend
            'is_html_allowed_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) seems obvious, but also see visible
            'apply_to' => join(',', $productTypes), // catalog_eav_attribute.apply_to (products only) which product types to apply to
            'is_configurable' => true, // catalog_eav_attribute.is_configurable (products only) used for configurable products or not
            'used_for_sort_by' => false, // catalog_eav_attribute.used_for_sort_by (products only) available in the 'sort by' menu
            'position' => 0, // catalog_eav_attribute.position (products only) position in layered naviagtion
            'used_for_promo_rules' => false, // catalog_eav_attribute.is_used_for_promo_rules (products only) available for use in promo rules
            )
            );



            $addAttribute->endSetup();


            /**
            * Add Attibute To Set
            */


            $addAttributeToSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
            /* @var $addAttributeToSet Mage_Catalog_Model_Resource_Setup */


            $attributeId = $addAttributeToSet->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute');
            $attributeSetId = $addAttributeToSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Custom');
            $attributeGroupId = $addAttributeToSet->getAttributeGroup(Mage_Catalog_Model_Product::ENTITY, $attributeSetId, 'General');
            $addAttributeToSet->addAttributeToSet(
            Mage_Catalog_Model_Product::ENTITY,
            $attributeSetId,
            $attributeGroupId,
            $attributeId
            );


            $addAttributeToSet->endSetup();






            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%2f282277%2fhow-to-create-an-attribute-in-magento-1-9%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              You cannot define the attribute set when creating the attribute with this method. Change group to undefined and set user_defined as true to create an attribute without setting an attribute set. After creating it, add the attribute to an attribute set in the upgrade or setup script.






              share|improve this answer



























                0














                You cannot define the attribute set when creating the attribute with this method. Change group to undefined and set user_defined as true to create an attribute without setting an attribute set. After creating it, add the attribute to an attribute set in the upgrade or setup script.






                share|improve this answer

























                  0












                  0








                  0







                  You cannot define the attribute set when creating the attribute with this method. Change group to undefined and set user_defined as true to create an attribute without setting an attribute set. After creating it, add the attribute to an attribute set in the upgrade or setup script.






                  share|improve this answer













                  You cannot define the attribute set when creating the attribute with this method. Change group to undefined and set user_defined as true to create an attribute without setting an attribute set. After creating it, add the attribute to an attribute set in the upgrade or setup script.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 16 at 18:14









                  MehdiMehdi

                  6547 silver badges23 bronze badges




                  6547 silver badges23 bronze badges























                      0














                      You can do it as part of install script




                      /**
                      * Add blank attibute set
                      */
                      $attibuteSet = new Mage_Eav_Model_Entity_Setup('core_setup');
                      /* @var $attibuteSet Mage_Eav_Model_Entity_Setup */
                      $attibuteSet->startSetup();
                      $attibuteSet->addAttributeSet(
                      Mage_Catalog_Model_Product::ENTITY, 'Custom'
                      );
                      $attibuteSet->endSetup();


                      /**
                      * Add attibute set based on default set
                      */
                      $attibuteSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
                      $attibuteSet->startSetup();
                      $defaultAttributeSetId = $attibuteSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Default');
                      $entityTypeId = $attibuteSet->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
                      $attributeSetsName = array('CustomTwo');


                      foreach ($attributeSetsName as $attributeSetName)

                      $model = Mage::getModel('eav/entity_attribute_set')->setEntityTypeId($entityTypeId);
                      $model->setAttributeSetName($attributeSetName);


                      try
                      if ($model->validate())
                      $model->save();
                      $model->initFromSkeleton($defaultAttributeSetId);
                      $model->save();

                      catch (Exception $e)
                      Mage::logException($e);


                      $attibuteSet->endSetup();


                      /**
                      * Add Attibute
                      */
                      $addAttribute = new Mage_Catalog_Model_Resource_Setup('core_setup');
                      /* @var $attribute Mage_Catalog_Model_Resource_Setup */
                      $productTypes = array(
                      Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
                      Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
                      );


                      $addAttribute->startSetup();


                      if (!$addAttribute->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute'))
                      $addAttribute->addAttribute(
                      Mage_Catalog_Model_Product::ENTITY,
                      'custom_attribute',
                      array( // TABLE.COLUMN: DESCRIPTION:
                      'label' => 'Custom Attribute', // eav_attribute.frontend_label admin input label
                      'group' => 'General', // (not a column) tab in product edit screen
                      'sort_order' => 0, // eav_entity_attribute.sort_order sort order in group
                      'backend' => '', // eav_attribute.backend_model backend class (module/class_name format)
                      'type' => 'varchar', // eav_attribute.backend_type backend storage type (varchar, text etc)
                      'frontend' => '', // eav_attribute.frontend_model admin class (module/class_name format)
                      'note' => null, // eav_attribute.note admin input note (shows below input)
                      'default' => null, // eav_attribute.default_value admin input default value
                      'wysiwyg_enabled' => false, // catalog_eav_attribute.is_wysiwyg_enabled (products only) admin input wysiwyg enabled
                      'input' => 'text', // eav_attribute.frontend_input admin input type (select, text, textarea etc)
                      'input_renderer' => false, // catalog_eav_attribute.frontend_input_renderer (products only) admin input renderer (otherwise input is used to resolve renderer)
                      'source' => null, // eav_attribute.source_model admin input source model (for selects) (module/class_name format)
                      'required' => false, // eav_attribute.is_required required in admin
                      'user_defined' => true, // eav_attribute.is_user_defined editable in admin attributes section, false for not
                      'unique' => false, // eav_attribute.is_unique unique value required
                      'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // catalog_eav_attribute.is_global (products only) scope
                      'visible' => true, // catalog_eav_attribute.is_visible (products only) visible on admin
                      'visible_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) visible on frontend (store) attribute table
                      'used_in_product_listing' => false, // catalog_eav_attribute.used_in_product_listing (products only) made available in product listing
                      'searchable' => false, // catalog_eav_attribute.is_searchable (products only) searchable via basic search
                      'visible_in_advanced_search' => false, // catalog_eav_attribute.is_visible_in_advanced_search (products only) searchable via advanced search
                      'filterable' => false, // catalog_eav_attribute.is_filterable (products only) use in layered nav
                      'filterable_in_search' => false, // catalog_eav_attribute.is_filterable_in_search (products only) use in search results layered nav
                      'comparable' => false, // catalog_eav_attribute.is_comparable (products only) comparable on frontend
                      'is_html_allowed_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) seems obvious, but also see visible
                      'apply_to' => join(',', $productTypes), // catalog_eav_attribute.apply_to (products only) which product types to apply to
                      'is_configurable' => true, // catalog_eav_attribute.is_configurable (products only) used for configurable products or not
                      'used_for_sort_by' => false, // catalog_eav_attribute.used_for_sort_by (products only) available in the 'sort by' menu
                      'position' => 0, // catalog_eav_attribute.position (products only) position in layered naviagtion
                      'used_for_promo_rules' => false, // catalog_eav_attribute.is_used_for_promo_rules (products only) available for use in promo rules
                      )
                      );



                      $addAttribute->endSetup();


                      /**
                      * Add Attibute To Set
                      */


                      $addAttributeToSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
                      /* @var $addAttributeToSet Mage_Catalog_Model_Resource_Setup */


                      $attributeId = $addAttributeToSet->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute');
                      $attributeSetId = $addAttributeToSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Custom');
                      $attributeGroupId = $addAttributeToSet->getAttributeGroup(Mage_Catalog_Model_Product::ENTITY, $attributeSetId, 'General');
                      $addAttributeToSet->addAttributeToSet(
                      Mage_Catalog_Model_Product::ENTITY,
                      $attributeSetId,
                      $attributeGroupId,
                      $attributeId
                      );


                      $addAttributeToSet->endSetup();






                      share|improve this answer



























                        0














                        You can do it as part of install script




                        /**
                        * Add blank attibute set
                        */
                        $attibuteSet = new Mage_Eav_Model_Entity_Setup('core_setup');
                        /* @var $attibuteSet Mage_Eav_Model_Entity_Setup */
                        $attibuteSet->startSetup();
                        $attibuteSet->addAttributeSet(
                        Mage_Catalog_Model_Product::ENTITY, 'Custom'
                        );
                        $attibuteSet->endSetup();


                        /**
                        * Add attibute set based on default set
                        */
                        $attibuteSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
                        $attibuteSet->startSetup();
                        $defaultAttributeSetId = $attibuteSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Default');
                        $entityTypeId = $attibuteSet->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
                        $attributeSetsName = array('CustomTwo');


                        foreach ($attributeSetsName as $attributeSetName)

                        $model = Mage::getModel('eav/entity_attribute_set')->setEntityTypeId($entityTypeId);
                        $model->setAttributeSetName($attributeSetName);


                        try
                        if ($model->validate())
                        $model->save();
                        $model->initFromSkeleton($defaultAttributeSetId);
                        $model->save();

                        catch (Exception $e)
                        Mage::logException($e);


                        $attibuteSet->endSetup();


                        /**
                        * Add Attibute
                        */
                        $addAttribute = new Mage_Catalog_Model_Resource_Setup('core_setup');
                        /* @var $attribute Mage_Catalog_Model_Resource_Setup */
                        $productTypes = array(
                        Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
                        Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
                        );


                        $addAttribute->startSetup();


                        if (!$addAttribute->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute'))
                        $addAttribute->addAttribute(
                        Mage_Catalog_Model_Product::ENTITY,
                        'custom_attribute',
                        array( // TABLE.COLUMN: DESCRIPTION:
                        'label' => 'Custom Attribute', // eav_attribute.frontend_label admin input label
                        'group' => 'General', // (not a column) tab in product edit screen
                        'sort_order' => 0, // eav_entity_attribute.sort_order sort order in group
                        'backend' => '', // eav_attribute.backend_model backend class (module/class_name format)
                        'type' => 'varchar', // eav_attribute.backend_type backend storage type (varchar, text etc)
                        'frontend' => '', // eav_attribute.frontend_model admin class (module/class_name format)
                        'note' => null, // eav_attribute.note admin input note (shows below input)
                        'default' => null, // eav_attribute.default_value admin input default value
                        'wysiwyg_enabled' => false, // catalog_eav_attribute.is_wysiwyg_enabled (products only) admin input wysiwyg enabled
                        'input' => 'text', // eav_attribute.frontend_input admin input type (select, text, textarea etc)
                        'input_renderer' => false, // catalog_eav_attribute.frontend_input_renderer (products only) admin input renderer (otherwise input is used to resolve renderer)
                        'source' => null, // eav_attribute.source_model admin input source model (for selects) (module/class_name format)
                        'required' => false, // eav_attribute.is_required required in admin
                        'user_defined' => true, // eav_attribute.is_user_defined editable in admin attributes section, false for not
                        'unique' => false, // eav_attribute.is_unique unique value required
                        'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // catalog_eav_attribute.is_global (products only) scope
                        'visible' => true, // catalog_eav_attribute.is_visible (products only) visible on admin
                        'visible_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) visible on frontend (store) attribute table
                        'used_in_product_listing' => false, // catalog_eav_attribute.used_in_product_listing (products only) made available in product listing
                        'searchable' => false, // catalog_eav_attribute.is_searchable (products only) searchable via basic search
                        'visible_in_advanced_search' => false, // catalog_eav_attribute.is_visible_in_advanced_search (products only) searchable via advanced search
                        'filterable' => false, // catalog_eav_attribute.is_filterable (products only) use in layered nav
                        'filterable_in_search' => false, // catalog_eav_attribute.is_filterable_in_search (products only) use in search results layered nav
                        'comparable' => false, // catalog_eav_attribute.is_comparable (products only) comparable on frontend
                        'is_html_allowed_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) seems obvious, but also see visible
                        'apply_to' => join(',', $productTypes), // catalog_eav_attribute.apply_to (products only) which product types to apply to
                        'is_configurable' => true, // catalog_eav_attribute.is_configurable (products only) used for configurable products or not
                        'used_for_sort_by' => false, // catalog_eav_attribute.used_for_sort_by (products only) available in the 'sort by' menu
                        'position' => 0, // catalog_eav_attribute.position (products only) position in layered naviagtion
                        'used_for_promo_rules' => false, // catalog_eav_attribute.is_used_for_promo_rules (products only) available for use in promo rules
                        )
                        );



                        $addAttribute->endSetup();


                        /**
                        * Add Attibute To Set
                        */


                        $addAttributeToSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
                        /* @var $addAttributeToSet Mage_Catalog_Model_Resource_Setup */


                        $attributeId = $addAttributeToSet->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute');
                        $attributeSetId = $addAttributeToSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Custom');
                        $attributeGroupId = $addAttributeToSet->getAttributeGroup(Mage_Catalog_Model_Product::ENTITY, $attributeSetId, 'General');
                        $addAttributeToSet->addAttributeToSet(
                        Mage_Catalog_Model_Product::ENTITY,
                        $attributeSetId,
                        $attributeGroupId,
                        $attributeId
                        );


                        $addAttributeToSet->endSetup();






                        share|improve this answer

























                          0












                          0








                          0







                          You can do it as part of install script




                          /**
                          * Add blank attibute set
                          */
                          $attibuteSet = new Mage_Eav_Model_Entity_Setup('core_setup');
                          /* @var $attibuteSet Mage_Eav_Model_Entity_Setup */
                          $attibuteSet->startSetup();
                          $attibuteSet->addAttributeSet(
                          Mage_Catalog_Model_Product::ENTITY, 'Custom'
                          );
                          $attibuteSet->endSetup();


                          /**
                          * Add attibute set based on default set
                          */
                          $attibuteSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
                          $attibuteSet->startSetup();
                          $defaultAttributeSetId = $attibuteSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Default');
                          $entityTypeId = $attibuteSet->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
                          $attributeSetsName = array('CustomTwo');


                          foreach ($attributeSetsName as $attributeSetName)

                          $model = Mage::getModel('eav/entity_attribute_set')->setEntityTypeId($entityTypeId);
                          $model->setAttributeSetName($attributeSetName);


                          try
                          if ($model->validate())
                          $model->save();
                          $model->initFromSkeleton($defaultAttributeSetId);
                          $model->save();

                          catch (Exception $e)
                          Mage::logException($e);


                          $attibuteSet->endSetup();


                          /**
                          * Add Attibute
                          */
                          $addAttribute = new Mage_Catalog_Model_Resource_Setup('core_setup');
                          /* @var $attribute Mage_Catalog_Model_Resource_Setup */
                          $productTypes = array(
                          Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
                          Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
                          );


                          $addAttribute->startSetup();


                          if (!$addAttribute->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute'))
                          $addAttribute->addAttribute(
                          Mage_Catalog_Model_Product::ENTITY,
                          'custom_attribute',
                          array( // TABLE.COLUMN: DESCRIPTION:
                          'label' => 'Custom Attribute', // eav_attribute.frontend_label admin input label
                          'group' => 'General', // (not a column) tab in product edit screen
                          'sort_order' => 0, // eav_entity_attribute.sort_order sort order in group
                          'backend' => '', // eav_attribute.backend_model backend class (module/class_name format)
                          'type' => 'varchar', // eav_attribute.backend_type backend storage type (varchar, text etc)
                          'frontend' => '', // eav_attribute.frontend_model admin class (module/class_name format)
                          'note' => null, // eav_attribute.note admin input note (shows below input)
                          'default' => null, // eav_attribute.default_value admin input default value
                          'wysiwyg_enabled' => false, // catalog_eav_attribute.is_wysiwyg_enabled (products only) admin input wysiwyg enabled
                          'input' => 'text', // eav_attribute.frontend_input admin input type (select, text, textarea etc)
                          'input_renderer' => false, // catalog_eav_attribute.frontend_input_renderer (products only) admin input renderer (otherwise input is used to resolve renderer)
                          'source' => null, // eav_attribute.source_model admin input source model (for selects) (module/class_name format)
                          'required' => false, // eav_attribute.is_required required in admin
                          'user_defined' => true, // eav_attribute.is_user_defined editable in admin attributes section, false for not
                          'unique' => false, // eav_attribute.is_unique unique value required
                          'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // catalog_eav_attribute.is_global (products only) scope
                          'visible' => true, // catalog_eav_attribute.is_visible (products only) visible on admin
                          'visible_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) visible on frontend (store) attribute table
                          'used_in_product_listing' => false, // catalog_eav_attribute.used_in_product_listing (products only) made available in product listing
                          'searchable' => false, // catalog_eav_attribute.is_searchable (products only) searchable via basic search
                          'visible_in_advanced_search' => false, // catalog_eav_attribute.is_visible_in_advanced_search (products only) searchable via advanced search
                          'filterable' => false, // catalog_eav_attribute.is_filterable (products only) use in layered nav
                          'filterable_in_search' => false, // catalog_eav_attribute.is_filterable_in_search (products only) use in search results layered nav
                          'comparable' => false, // catalog_eav_attribute.is_comparable (products only) comparable on frontend
                          'is_html_allowed_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) seems obvious, but also see visible
                          'apply_to' => join(',', $productTypes), // catalog_eav_attribute.apply_to (products only) which product types to apply to
                          'is_configurable' => true, // catalog_eav_attribute.is_configurable (products only) used for configurable products or not
                          'used_for_sort_by' => false, // catalog_eav_attribute.used_for_sort_by (products only) available in the 'sort by' menu
                          'position' => 0, // catalog_eav_attribute.position (products only) position in layered naviagtion
                          'used_for_promo_rules' => false, // catalog_eav_attribute.is_used_for_promo_rules (products only) available for use in promo rules
                          )
                          );



                          $addAttribute->endSetup();


                          /**
                          * Add Attibute To Set
                          */


                          $addAttributeToSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
                          /* @var $addAttributeToSet Mage_Catalog_Model_Resource_Setup */


                          $attributeId = $addAttributeToSet->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute');
                          $attributeSetId = $addAttributeToSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Custom');
                          $attributeGroupId = $addAttributeToSet->getAttributeGroup(Mage_Catalog_Model_Product::ENTITY, $attributeSetId, 'General');
                          $addAttributeToSet->addAttributeToSet(
                          Mage_Catalog_Model_Product::ENTITY,
                          $attributeSetId,
                          $attributeGroupId,
                          $attributeId
                          );


                          $addAttributeToSet->endSetup();






                          share|improve this answer













                          You can do it as part of install script




                          /**
                          * Add blank attibute set
                          */
                          $attibuteSet = new Mage_Eav_Model_Entity_Setup('core_setup');
                          /* @var $attibuteSet Mage_Eav_Model_Entity_Setup */
                          $attibuteSet->startSetup();
                          $attibuteSet->addAttributeSet(
                          Mage_Catalog_Model_Product::ENTITY, 'Custom'
                          );
                          $attibuteSet->endSetup();


                          /**
                          * Add attibute set based on default set
                          */
                          $attibuteSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
                          $attibuteSet->startSetup();
                          $defaultAttributeSetId = $attibuteSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Default');
                          $entityTypeId = $attibuteSet->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
                          $attributeSetsName = array('CustomTwo');


                          foreach ($attributeSetsName as $attributeSetName)

                          $model = Mage::getModel('eav/entity_attribute_set')->setEntityTypeId($entityTypeId);
                          $model->setAttributeSetName($attributeSetName);


                          try
                          if ($model->validate())
                          $model->save();
                          $model->initFromSkeleton($defaultAttributeSetId);
                          $model->save();

                          catch (Exception $e)
                          Mage::logException($e);


                          $attibuteSet->endSetup();


                          /**
                          * Add Attibute
                          */
                          $addAttribute = new Mage_Catalog_Model_Resource_Setup('core_setup');
                          /* @var $attribute Mage_Catalog_Model_Resource_Setup */
                          $productTypes = array(
                          Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
                          Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
                          );


                          $addAttribute->startSetup();


                          if (!$addAttribute->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute'))
                          $addAttribute->addAttribute(
                          Mage_Catalog_Model_Product::ENTITY,
                          'custom_attribute',
                          array( // TABLE.COLUMN: DESCRIPTION:
                          'label' => 'Custom Attribute', // eav_attribute.frontend_label admin input label
                          'group' => 'General', // (not a column) tab in product edit screen
                          'sort_order' => 0, // eav_entity_attribute.sort_order sort order in group
                          'backend' => '', // eav_attribute.backend_model backend class (module/class_name format)
                          'type' => 'varchar', // eav_attribute.backend_type backend storage type (varchar, text etc)
                          'frontend' => '', // eav_attribute.frontend_model admin class (module/class_name format)
                          'note' => null, // eav_attribute.note admin input note (shows below input)
                          'default' => null, // eav_attribute.default_value admin input default value
                          'wysiwyg_enabled' => false, // catalog_eav_attribute.is_wysiwyg_enabled (products only) admin input wysiwyg enabled
                          'input' => 'text', // eav_attribute.frontend_input admin input type (select, text, textarea etc)
                          'input_renderer' => false, // catalog_eav_attribute.frontend_input_renderer (products only) admin input renderer (otherwise input is used to resolve renderer)
                          'source' => null, // eav_attribute.source_model admin input source model (for selects) (module/class_name format)
                          'required' => false, // eav_attribute.is_required required in admin
                          'user_defined' => true, // eav_attribute.is_user_defined editable in admin attributes section, false for not
                          'unique' => false, // eav_attribute.is_unique unique value required
                          'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // catalog_eav_attribute.is_global (products only) scope
                          'visible' => true, // catalog_eav_attribute.is_visible (products only) visible on admin
                          'visible_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) visible on frontend (store) attribute table
                          'used_in_product_listing' => false, // catalog_eav_attribute.used_in_product_listing (products only) made available in product listing
                          'searchable' => false, // catalog_eav_attribute.is_searchable (products only) searchable via basic search
                          'visible_in_advanced_search' => false, // catalog_eav_attribute.is_visible_in_advanced_search (products only) searchable via advanced search
                          'filterable' => false, // catalog_eav_attribute.is_filterable (products only) use in layered nav
                          'filterable_in_search' => false, // catalog_eav_attribute.is_filterable_in_search (products only) use in search results layered nav
                          'comparable' => false, // catalog_eav_attribute.is_comparable (products only) comparable on frontend
                          'is_html_allowed_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) seems obvious, but also see visible
                          'apply_to' => join(',', $productTypes), // catalog_eav_attribute.apply_to (products only) which product types to apply to
                          'is_configurable' => true, // catalog_eav_attribute.is_configurable (products only) used for configurable products or not
                          'used_for_sort_by' => false, // catalog_eav_attribute.used_for_sort_by (products only) available in the 'sort by' menu
                          'position' => 0, // catalog_eav_attribute.position (products only) position in layered naviagtion
                          'used_for_promo_rules' => false, // catalog_eav_attribute.is_used_for_promo_rules (products only) available for use in promo rules
                          )
                          );



                          $addAttribute->endSetup();


                          /**
                          * Add Attibute To Set
                          */


                          $addAttributeToSet = new Mage_Catalog_Model_Resource_Setup('core_setup');
                          /* @var $addAttributeToSet Mage_Catalog_Model_Resource_Setup */


                          $attributeId = $addAttributeToSet->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'custom_attribute');
                          $attributeSetId = $addAttributeToSet->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Custom');
                          $attributeGroupId = $addAttributeToSet->getAttributeGroup(Mage_Catalog_Model_Product::ENTITY, $attributeSetId, 'General');
                          $addAttributeToSet->addAttributeToSet(
                          Mage_Catalog_Model_Product::ENTITY,
                          $attributeSetId,
                          $attributeGroupId,
                          $attributeId
                          );


                          $addAttributeToSet->endSetup();







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jul 16 at 20:06









                          Dominic XigenDominic Xigen

                          3,0641 gold badge5 silver badges17 bronze badges




                          3,0641 gold badge5 silver badges17 bronze badges



























                              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%2f282277%2fhow-to-create-an-attribute-in-magento-1-9%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

                              Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                              Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                              Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form