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

Is it safe to keep the GPU on 100% utilization for a very long time?

What happens when the drag force exceeds the weight of an object falling into earth?

shebang or not shebang

The unknown and unexplained in science fiction

Are wands in any sort of book going to be too much like Harry Potter?

How do I minimise waste on a flight?

Concatenate all values of the same XML element using XPath/XQuery

Did any early RISC OS precursor run on the BBC Micro?

Single supply non-inverting amplifier using op amp

Employee is self-centered and affects the team negatively

Why always 4...dxc6 and not 4...bxc6 in the Ruy Lopez Exchange?

TikZ/PGF draw algorithm

Learning how to read schematics, questions about fractional voltage in schematic

How can I test a shell script in a "safe environment" to avoid harm to my computer?

A♭ major 9th chord in Bach is unexpectedly dissonant/jazzy

What detail can Hubble see on Mars?

Drug Testing and Prescribed Medications

Justification of physical currency in an interstellar civilization?

Why was Gemini VIII terminated after recovering from the OAMS thruster failure?

What do I compare this series to?

Steam family share questions

Why is it that forces like gravity and electricity (approximately) basically act between pairs of bodies only?

Which "exotic salt" can lower water's freezing point by 70 °C?

Why is the episode called "The Last of the Starks"?



Get product attribute by attribute group code in magento 2


get 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






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








1















Please help.
I want get attribute by [attribute_group_code]. Please help me. My code is as follows:



<?php
$product = $this->getProduct();
$attributeSetId = $product->getAttributeSetId();
$groupCollection = $this->groupCollectionFactory->create()
->setAttributeSetFilter($attributeSetId)
->setSortOrder()
->load();
foreach ($groupCollection as $group) :
$attributes = $product->getAttributes();
echo "<pre>";
print_r ($group->getData());
echo "</pre>";
?>
Return :
Array
(
[attribute_group_id] => 21
[attribute_set_id] => 4
[attribute_group_name] => Operate
[sort_order] => 3
[default_id] => 0
[attribute_group_code] => operate
[tab_group_code] =>
)

// Get attribute value , label
<?php endforeach; ?>


I just want to get these attribute groups (operate) values based on ['attribute_group_code']. Because when creating the attribute group in admin, I will not know the id of the attribute group, so I only rely on the attribute_group_code.
Thank you.










share|improve this question






























    1















    Please help.
    I want get attribute by [attribute_group_code]. Please help me. My code is as follows:



    <?php
    $product = $this->getProduct();
    $attributeSetId = $product->getAttributeSetId();
    $groupCollection = $this->groupCollectionFactory->create()
    ->setAttributeSetFilter($attributeSetId)
    ->setSortOrder()
    ->load();
    foreach ($groupCollection as $group) :
    $attributes = $product->getAttributes();
    echo "<pre>";
    print_r ($group->getData());
    echo "</pre>";
    ?>
    Return :
    Array
    (
    [attribute_group_id] => 21
    [attribute_set_id] => 4
    [attribute_group_name] => Operate
    [sort_order] => 3
    [default_id] => 0
    [attribute_group_code] => operate
    [tab_group_code] =>
    )

    // Get attribute value , label
    <?php endforeach; ?>


    I just want to get these attribute groups (operate) values based on ['attribute_group_code']. Because when creating the attribute group in admin, I will not know the id of the attribute group, so I only rely on the attribute_group_code.
    Thank you.










    share|improve this question


























      1












      1








      1








      Please help.
      I want get attribute by [attribute_group_code]. Please help me. My code is as follows:



      <?php
      $product = $this->getProduct();
      $attributeSetId = $product->getAttributeSetId();
      $groupCollection = $this->groupCollectionFactory->create()
      ->setAttributeSetFilter($attributeSetId)
      ->setSortOrder()
      ->load();
      foreach ($groupCollection as $group) :
      $attributes = $product->getAttributes();
      echo "<pre>";
      print_r ($group->getData());
      echo "</pre>";
      ?>
      Return :
      Array
      (
      [attribute_group_id] => 21
      [attribute_set_id] => 4
      [attribute_group_name] => Operate
      [sort_order] => 3
      [default_id] => 0
      [attribute_group_code] => operate
      [tab_group_code] =>
      )

      // Get attribute value , label
      <?php endforeach; ?>


      I just want to get these attribute groups (operate) values based on ['attribute_group_code']. Because when creating the attribute group in admin, I will not know the id of the attribute group, so I only rely on the attribute_group_code.
      Thank you.










      share|improve this question
















      Please help.
      I want get attribute by [attribute_group_code]. Please help me. My code is as follows:



      <?php
      $product = $this->getProduct();
      $attributeSetId = $product->getAttributeSetId();
      $groupCollection = $this->groupCollectionFactory->create()
      ->setAttributeSetFilter($attributeSetId)
      ->setSortOrder()
      ->load();
      foreach ($groupCollection as $group) :
      $attributes = $product->getAttributes();
      echo "<pre>";
      print_r ($group->getData());
      echo "</pre>";
      ?>
      Return :
      Array
      (
      [attribute_group_id] => 21
      [attribute_set_id] => 4
      [attribute_group_name] => Operate
      [sort_order] => 3
      [default_id] => 0
      [attribute_group_code] => operate
      [tab_group_code] =>
      )

      // Get attribute value , label
      <?php endforeach; ?>


      I just want to get these attribute groups (operate) values based on ['attribute_group_code']. Because when creating the attribute group in admin, I will not know the id of the attribute group, so I only rely on the attribute_group_code.
      Thank you.







      magento2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      Daniel

      371214




      371214










      asked May 4 at 7:49









      RogerRoger

      515




      515




















          1 Answer
          1






          active

          oldest

          votes


















          1














          You can get the product attributes within a specific attribute group by passing the attribute group id to $product->getAttributes($groupId)



          So in your foreach ($groupCollection as $group) you can do the following:



          if ($group->getAttributeGroupCode() == 'your_attribute_code') 
          $groupId = $group->getAttributeGroupId();
          else
          continue; //it's the wrong group so you can continue with the next



          With this you get $groupId and you can get your product attributes of the group with:
          $product->getAttributes($groupId)






          share|improve this answer























          • Thanks for your support

            – Roger
            yesterday











          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%2f273410%2fget-product-attribute-by-attribute-group-code-in-magento-2%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You can get the product attributes within a specific attribute group by passing the attribute group id to $product->getAttributes($groupId)



          So in your foreach ($groupCollection as $group) you can do the following:



          if ($group->getAttributeGroupCode() == 'your_attribute_code') 
          $groupId = $group->getAttributeGroupId();
          else
          continue; //it's the wrong group so you can continue with the next



          With this you get $groupId and you can get your product attributes of the group with:
          $product->getAttributes($groupId)






          share|improve this answer























          • Thanks for your support

            – Roger
            yesterday















          1














          You can get the product attributes within a specific attribute group by passing the attribute group id to $product->getAttributes($groupId)



          So in your foreach ($groupCollection as $group) you can do the following:



          if ($group->getAttributeGroupCode() == 'your_attribute_code') 
          $groupId = $group->getAttributeGroupId();
          else
          continue; //it's the wrong group so you can continue with the next



          With this you get $groupId and you can get your product attributes of the group with:
          $product->getAttributes($groupId)






          share|improve this answer























          • Thanks for your support

            – Roger
            yesterday













          1












          1








          1







          You can get the product attributes within a specific attribute group by passing the attribute group id to $product->getAttributes($groupId)



          So in your foreach ($groupCollection as $group) you can do the following:



          if ($group->getAttributeGroupCode() == 'your_attribute_code') 
          $groupId = $group->getAttributeGroupId();
          else
          continue; //it's the wrong group so you can continue with the next



          With this you get $groupId and you can get your product attributes of the group with:
          $product->getAttributes($groupId)






          share|improve this answer













          You can get the product attributes within a specific attribute group by passing the attribute group id to $product->getAttributes($groupId)



          So in your foreach ($groupCollection as $group) you can do the following:



          if ($group->getAttributeGroupCode() == 'your_attribute_code') 
          $groupId = $group->getAttributeGroupId();
          else
          continue; //it's the wrong group so you can continue with the next



          With this you get $groupId and you can get your product attributes of the group with:
          $product->getAttributes($groupId)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          DanielDaniel

          371214




          371214












          • Thanks for your support

            – Roger
            yesterday

















          • Thanks for your support

            – Roger
            yesterday
















          Thanks for your support

          – Roger
          yesterday





          Thanks for your support

          – Roger
          yesterday

















          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%2f273410%2fget-product-attribute-by-attribute-group-code-in-magento-2%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

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

          Get RecordId in LWC From Community PageLWC Community recordId undefinedhow to get Personal Access Token from my integrated application LWC. I am using js onlylwc quick action from Opportunity page(aura:component) and not getting @api recordIdLWC Community recordId undefinedLWC - How to get label name of buttonsLWC: Add a region in custom community themeVisual force page redirection from lightning communityLWC NavigationMixin does not work in CommunityInvoking LWC component from a plain URL - Read URL Parameter inside LWCLWC download PDF fileLWC Get Pick-list Field Values