Create Product Attribute Of Type MULTISELECT or dropdown select & Create Option Labels Diffrent for...












4














I am creating custom Product Attribute Of type MULTI SELECT,



I want to create different option label for each stores for this particular Attribute,



I have tried with this below code,



$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'myattribute',
[
'type' => 'text',
'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
'frontend' => '',
'label' => 'My Attribute',
'input' => 'multiselect',
'class' => '',
'option' => ['values' =>
[
'0' => '1',
'1' => '2',
'2' => '3',
'3' => '4',
'4' => '5',
'5' => '6',
],
], // I have tried this way but not working
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'wysiwyg_enabled' => true,
'unique' => false,
'apply_to' => ''
]
);


With the above code, Attribute Options were inserted as a new row & I want it to be stored as store wise.



How can I achieve this thing.?










share|improve this question





























    4














    I am creating custom Product Attribute Of type MULTI SELECT,



    I want to create different option label for each stores for this particular Attribute,



    I have tried with this below code,



    $eavSetup->addAttribute(
    MagentoCatalogModelProduct::ENTITY,
    'myattribute',
    [
    'type' => 'text',
    'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
    'frontend' => '',
    'label' => 'My Attribute',
    'input' => 'multiselect',
    'class' => '',
    'option' => ['values' =>
    [
    '0' => '1',
    '1' => '2',
    '2' => '3',
    '3' => '4',
    '4' => '5',
    '5' => '6',
    ],
    ], // I have tried this way but not working
    'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
    'visible' => true,
    'required' => false,
    'user_defined' => true,
    'default' => '',
    'searchable' => false,
    'filterable' => false,
    'comparable' => false,
    'visible_on_front' => false,
    'used_in_product_listing' => true,
    'wysiwyg_enabled' => true,
    'unique' => false,
    'apply_to' => ''
    ]
    );


    With the above code, Attribute Options were inserted as a new row & I want it to be stored as store wise.



    How can I achieve this thing.?










    share|improve this question



























      4












      4








      4







      I am creating custom Product Attribute Of type MULTI SELECT,



      I want to create different option label for each stores for this particular Attribute,



      I have tried with this below code,



      $eavSetup->addAttribute(
      MagentoCatalogModelProduct::ENTITY,
      'myattribute',
      [
      'type' => 'text',
      'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
      'frontend' => '',
      'label' => 'My Attribute',
      'input' => 'multiselect',
      'class' => '',
      'option' => ['values' =>
      [
      '0' => '1',
      '1' => '2',
      '2' => '3',
      '3' => '4',
      '4' => '5',
      '5' => '6',
      ],
      ], // I have tried this way but not working
      'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
      'visible' => true,
      'required' => false,
      'user_defined' => true,
      'default' => '',
      'searchable' => false,
      'filterable' => false,
      'comparable' => false,
      'visible_on_front' => false,
      'used_in_product_listing' => true,
      'wysiwyg_enabled' => true,
      'unique' => false,
      'apply_to' => ''
      ]
      );


      With the above code, Attribute Options were inserted as a new row & I want it to be stored as store wise.



      How can I achieve this thing.?










      share|improve this question















      I am creating custom Product Attribute Of type MULTI SELECT,



      I want to create different option label for each stores for this particular Attribute,



      I have tried with this below code,



      $eavSetup->addAttribute(
      MagentoCatalogModelProduct::ENTITY,
      'myattribute',
      [
      'type' => 'text',
      'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
      'frontend' => '',
      'label' => 'My Attribute',
      'input' => 'multiselect',
      'class' => '',
      'option' => ['values' =>
      [
      '0' => '1',
      '1' => '2',
      '2' => '3',
      '3' => '4',
      '4' => '5',
      '5' => '6',
      ],
      ], // I have tried this way but not working
      'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
      'visible' => true,
      'required' => false,
      'user_defined' => true,
      'default' => '',
      'searchable' => false,
      'filterable' => false,
      'comparable' => false,
      'visible_on_front' => false,
      'used_in_product_listing' => true,
      'wysiwyg_enabled' => true,
      'unique' => false,
      'apply_to' => ''
      ]
      );


      With the above code, Attribute Options were inserted as a new row & I want it to be stored as store wise.



      How can I achieve this thing.?







      magento2 multistore dropdown-attribute multiselect-attribute attribute-options






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 2 '18 at 7:13









      Murtuza Zabuawala

      12.3k73260




      12.3k73260










      asked Nov 13 '17 at 12:17









      Rizwan

      626323




      626323






















          2 Answers
          2






          active

          oldest

          votes


















          3














          I have check the core how magento install the label and I found code in below file



          vendor/magento/module-eav/Setup/EavSetup.php



          in this file I got addAttributeOption method.



          After seeing the code I got your answer, create attribute like below



          You can create multiselect and dropdown attribute option label different on store basis like below



          $eavSetup->addAttribute(
          MagentoCatalogModelProduct::ENTITY,
          'myattribute',
          [
          'type' => 'text',
          'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
          'frontend' => '',
          'label' => 'My Attribute',
          'input' => 'multiselect',
          'class' => '',
          // instead values change your key as value and add your option like below with in `option_1` array put key as store_id and label as value
          'option' => ['value' =>
          [
          'option_1'=>[
          //option_1 will be static it will add below labels in option_1 for **new**
          0=>'label for admin', // here 0 is store id and 123 is value
          1=>'label for store1',
          13=>'label for store 13',
          14=>12121,
          15=>1212,
          16=>123
          ],
          'option_2'=>[
          0=>'label for admin',
          1=>'label for store1',
          13=>'label for store 13',
          14=>32123,
          15=>123123123,
          16=>5152
          ],
          ],
          'order'=>//Here We can Set Sort Order For Each Value.
          [
          'option_1'=>1,
          'option_2'=>2
          ]
          ],
          'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
          'visible' => true,
          'required' => false,
          'user_defined' => true,
          'default' => '',
          'searchable' => false,
          'filterable' => false,
          'comparable' => false,
          'visible_on_front' => false,
          'used_in_product_listing' => true,
          'wysiwyg_enabled' => true,
          'unique' => false,
          'apply_to' => ''
          ]
          );





          share|improve this answer































            0














            If i have a business and a personal store and want separate registration and drop down selection would i use this same method? also instead of




            'option_1'=>1,'option_2'=>2




            can i illustrate as




            option_personal'=>personal 'option_business'=>Business?




            and how would i point (depending on registration) to the correct store front end?



            Thank you @MurtuzaZabuawala






            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%2f201226%2fcreate-product-attribute-of-type-multiselect-or-dropdown-select-create-option%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









              3














              I have check the core how magento install the label and I found code in below file



              vendor/magento/module-eav/Setup/EavSetup.php



              in this file I got addAttributeOption method.



              After seeing the code I got your answer, create attribute like below



              You can create multiselect and dropdown attribute option label different on store basis like below



              $eavSetup->addAttribute(
              MagentoCatalogModelProduct::ENTITY,
              'myattribute',
              [
              'type' => 'text',
              'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
              'frontend' => '',
              'label' => 'My Attribute',
              'input' => 'multiselect',
              'class' => '',
              // instead values change your key as value and add your option like below with in `option_1` array put key as store_id and label as value
              'option' => ['value' =>
              [
              'option_1'=>[
              //option_1 will be static it will add below labels in option_1 for **new**
              0=>'label for admin', // here 0 is store id and 123 is value
              1=>'label for store1',
              13=>'label for store 13',
              14=>12121,
              15=>1212,
              16=>123
              ],
              'option_2'=>[
              0=>'label for admin',
              1=>'label for store1',
              13=>'label for store 13',
              14=>32123,
              15=>123123123,
              16=>5152
              ],
              ],
              'order'=>//Here We can Set Sort Order For Each Value.
              [
              'option_1'=>1,
              'option_2'=>2
              ]
              ],
              'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
              'visible' => true,
              'required' => false,
              'user_defined' => true,
              'default' => '',
              'searchable' => false,
              'filterable' => false,
              'comparable' => false,
              'visible_on_front' => false,
              'used_in_product_listing' => true,
              'wysiwyg_enabled' => true,
              'unique' => false,
              'apply_to' => ''
              ]
              );





              share|improve this answer




























                3














                I have check the core how magento install the label and I found code in below file



                vendor/magento/module-eav/Setup/EavSetup.php



                in this file I got addAttributeOption method.



                After seeing the code I got your answer, create attribute like below



                You can create multiselect and dropdown attribute option label different on store basis like below



                $eavSetup->addAttribute(
                MagentoCatalogModelProduct::ENTITY,
                'myattribute',
                [
                'type' => 'text',
                'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
                'frontend' => '',
                'label' => 'My Attribute',
                'input' => 'multiselect',
                'class' => '',
                // instead values change your key as value and add your option like below with in `option_1` array put key as store_id and label as value
                'option' => ['value' =>
                [
                'option_1'=>[
                //option_1 will be static it will add below labels in option_1 for **new**
                0=>'label for admin', // here 0 is store id and 123 is value
                1=>'label for store1',
                13=>'label for store 13',
                14=>12121,
                15=>1212,
                16=>123
                ],
                'option_2'=>[
                0=>'label for admin',
                1=>'label for store1',
                13=>'label for store 13',
                14=>32123,
                15=>123123123,
                16=>5152
                ],
                ],
                'order'=>//Here We can Set Sort Order For Each Value.
                [
                'option_1'=>1,
                'option_2'=>2
                ]
                ],
                'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
                'visible' => true,
                'required' => false,
                'user_defined' => true,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'wysiwyg_enabled' => true,
                'unique' => false,
                'apply_to' => ''
                ]
                );





                share|improve this answer


























                  3












                  3








                  3






                  I have check the core how magento install the label and I found code in below file



                  vendor/magento/module-eav/Setup/EavSetup.php



                  in this file I got addAttributeOption method.



                  After seeing the code I got your answer, create attribute like below



                  You can create multiselect and dropdown attribute option label different on store basis like below



                  $eavSetup->addAttribute(
                  MagentoCatalogModelProduct::ENTITY,
                  'myattribute',
                  [
                  'type' => 'text',
                  'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
                  'frontend' => '',
                  'label' => 'My Attribute',
                  'input' => 'multiselect',
                  'class' => '',
                  // instead values change your key as value and add your option like below with in `option_1` array put key as store_id and label as value
                  'option' => ['value' =>
                  [
                  'option_1'=>[
                  //option_1 will be static it will add below labels in option_1 for **new**
                  0=>'label for admin', // here 0 is store id and 123 is value
                  1=>'label for store1',
                  13=>'label for store 13',
                  14=>12121,
                  15=>1212,
                  16=>123
                  ],
                  'option_2'=>[
                  0=>'label for admin',
                  1=>'label for store1',
                  13=>'label for store 13',
                  14=>32123,
                  15=>123123123,
                  16=>5152
                  ],
                  ],
                  'order'=>//Here We can Set Sort Order For Each Value.
                  [
                  'option_1'=>1,
                  'option_2'=>2
                  ]
                  ],
                  'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
                  'visible' => true,
                  'required' => false,
                  'user_defined' => true,
                  'default' => '',
                  'searchable' => false,
                  'filterable' => false,
                  'comparable' => false,
                  'visible_on_front' => false,
                  'used_in_product_listing' => true,
                  'wysiwyg_enabled' => true,
                  'unique' => false,
                  'apply_to' => ''
                  ]
                  );





                  share|improve this answer














                  I have check the core how magento install the label and I found code in below file



                  vendor/magento/module-eav/Setup/EavSetup.php



                  in this file I got addAttributeOption method.



                  After seeing the code I got your answer, create attribute like below



                  You can create multiselect and dropdown attribute option label different on store basis like below



                  $eavSetup->addAttribute(
                  MagentoCatalogModelProduct::ENTITY,
                  'myattribute',
                  [
                  'type' => 'text',
                  'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
                  'frontend' => '',
                  'label' => 'My Attribute',
                  'input' => 'multiselect',
                  'class' => '',
                  // instead values change your key as value and add your option like below with in `option_1` array put key as store_id and label as value
                  'option' => ['value' =>
                  [
                  'option_1'=>[
                  //option_1 will be static it will add below labels in option_1 for **new**
                  0=>'label for admin', // here 0 is store id and 123 is value
                  1=>'label for store1',
                  13=>'label for store 13',
                  14=>12121,
                  15=>1212,
                  16=>123
                  ],
                  'option_2'=>[
                  0=>'label for admin',
                  1=>'label for store1',
                  13=>'label for store 13',
                  14=>32123,
                  15=>123123123,
                  16=>5152
                  ],
                  ],
                  'order'=>//Here We can Set Sort Order For Each Value.
                  [
                  'option_1'=>1,
                  'option_2'=>2
                  ]
                  ],
                  'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
                  'visible' => true,
                  'required' => false,
                  'user_defined' => true,
                  'default' => '',
                  'searchable' => false,
                  'filterable' => false,
                  'comparable' => false,
                  'visible_on_front' => false,
                  'used_in_product_listing' => true,
                  'wysiwyg_enabled' => true,
                  'unique' => false,
                  'apply_to' => ''
                  ]
                  );






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 2 '18 at 7:11

























                  answered Nov 13 '17 at 13:35









                  Murtuza Zabuawala

                  12.3k73260




                  12.3k73260

























                      0














                      If i have a business and a personal store and want separate registration and drop down selection would i use this same method? also instead of




                      'option_1'=>1,'option_2'=>2




                      can i illustrate as




                      option_personal'=>personal 'option_business'=>Business?




                      and how would i point (depending on registration) to the correct store front end?



                      Thank you @MurtuzaZabuawala






                      share|improve this answer


























                        0














                        If i have a business and a personal store and want separate registration and drop down selection would i use this same method? also instead of




                        'option_1'=>1,'option_2'=>2




                        can i illustrate as




                        option_personal'=>personal 'option_business'=>Business?




                        and how would i point (depending on registration) to the correct store front end?



                        Thank you @MurtuzaZabuawala






                        share|improve this answer
























                          0












                          0








                          0






                          If i have a business and a personal store and want separate registration and drop down selection would i use this same method? also instead of




                          'option_1'=>1,'option_2'=>2




                          can i illustrate as




                          option_personal'=>personal 'option_business'=>Business?




                          and how would i point (depending on registration) to the correct store front end?



                          Thank you @MurtuzaZabuawala






                          share|improve this answer












                          If i have a business and a personal store and want separate registration and drop down selection would i use this same method? also instead of




                          'option_1'=>1,'option_2'=>2




                          can i illustrate as




                          option_personal'=>personal 'option_business'=>Business?




                          and how would i point (depending on registration) to the correct store front end?



                          Thank you @MurtuzaZabuawala







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered yesterday









                          rav narayan

                          136




                          136






























                              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.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • 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%2f201226%2fcreate-product-attribute-of-type-multiselect-or-dropdown-select-create-option%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

                              An IMO inspired problem

                              Management

                              Has there ever been an instance of an active nuclear power plant within or near a war zone?