Getting the custom product attribute in the Checkout summary Magento 2












0















Hi i have a custom product attribute which for some reason we are using in place of name. I need to change this through out the site. I got success in getting this in minicart , product and cart page.
but i am unable to find how it is getting render on the checkout summary section



for minicart it is rendering from the file



vendor/magento/module-checkout/CustomerData/DefaultItem.php

protected function doGetItemData()
{
.......
return [
'options' => $this->getOptionList(),
'qty' => $this->item->getQty() * 1,
'item_id' => $this->item->getId(),
'configure_url' => $this->getConfigureUrl(),
'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
'product_name' => $this->item->getProduct()->getName(),
'product_url' => $this->getProductUrl(),
'product_has_url' => $this->hasProductUrl(),
.....
}


but in checkout summary i cant find how it works. Please suggest how can i achieve this.



Thanks










share|improve this question














bumped to the homepage by Community 4 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    Hi i have a custom product attribute which for some reason we are using in place of name. I need to change this through out the site. I got success in getting this in minicart , product and cart page.
    but i am unable to find how it is getting render on the checkout summary section



    for minicart it is rendering from the file



    vendor/magento/module-checkout/CustomerData/DefaultItem.php

    protected function doGetItemData()
    {
    .......
    return [
    'options' => $this->getOptionList(),
    'qty' => $this->item->getQty() * 1,
    'item_id' => $this->item->getId(),
    'configure_url' => $this->getConfigureUrl(),
    'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
    'product_name' => $this->item->getProduct()->getName(),
    'product_url' => $this->getProductUrl(),
    'product_has_url' => $this->hasProductUrl(),
    .....
    }


    but in checkout summary i cant find how it works. Please suggest how can i achieve this.



    Thanks










    share|improve this question














    bumped to the homepage by Community 4 hours ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      Hi i have a custom product attribute which for some reason we are using in place of name. I need to change this through out the site. I got success in getting this in minicart , product and cart page.
      but i am unable to find how it is getting render on the checkout summary section



      for minicart it is rendering from the file



      vendor/magento/module-checkout/CustomerData/DefaultItem.php

      protected function doGetItemData()
      {
      .......
      return [
      'options' => $this->getOptionList(),
      'qty' => $this->item->getQty() * 1,
      'item_id' => $this->item->getId(),
      'configure_url' => $this->getConfigureUrl(),
      'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
      'product_name' => $this->item->getProduct()->getName(),
      'product_url' => $this->getProductUrl(),
      'product_has_url' => $this->hasProductUrl(),
      .....
      }


      but in checkout summary i cant find how it works. Please suggest how can i achieve this.



      Thanks










      share|improve this question














      Hi i have a custom product attribute which for some reason we are using in place of name. I need to change this through out the site. I got success in getting this in minicart , product and cart page.
      but i am unable to find how it is getting render on the checkout summary section



      for minicart it is rendering from the file



      vendor/magento/module-checkout/CustomerData/DefaultItem.php

      protected function doGetItemData()
      {
      .......
      return [
      'options' => $this->getOptionList(),
      'qty' => $this->item->getQty() * 1,
      'item_id' => $this->item->getId(),
      'configure_url' => $this->getConfigureUrl(),
      'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
      'product_name' => $this->item->getProduct()->getName(),
      'product_url' => $this->getProductUrl(),
      'product_has_url' => $this->hasProductUrl(),
      .....
      }


      but in checkout summary i cant find how it works. Please suggest how can i achieve this.



      Thanks







      magento2 product checkout attributes data






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 6 '17 at 7:36









      Rohit GoelRohit Goel

      20819




      20819





      bumped to the homepage by Community 4 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 4 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You will have to create a plugin for that. I wanted to add product flavor to order summary. This is the way I created a plugin and achieved what I wanted.



          Vendor = Sejal



          Files you need to create:




          1. Registration.php : appcodeSejalFlavorregistration.php

          2. di.xml : appcodeSejalFlavoretcdi.xml

          3. module.xml : appcodeSejalFlavoretcdi.xml

          4. ConfigProviderPlugin.php : appcodeSejalFlavorPluginConfigProviderPlugin.php

          5. details.html : copy of vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html


          you can override this file in your theme like this



          appdesignfrontendVendorthemenameMagento_Checkoutwebtemplatesummaryitemdetails.html



          Code:
          registration.php



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE,
          'Sejal_Flavor',
          __DIR__
          );


          di.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCheckoutModelDefaultConfigProvider">
          <plugin name="AddAttPlug" type="SejalFlavorPluginConfigProviderPlugin" />
          </type>
          </config>


          module.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
          <module name="Sejal_Flavor" setup_version="1.0.0">
          </module>
          </config>


          ConfigProviderPlugin.php



          <?php

          namespace SejalFlavorPlugin;

          class ConfigProviderPlugin extends MagentoFrameworkModelAbstractModel
          {

          public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, array $result)
          {

          $items = $result['totalsData']['items'];

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          for($i=0;$i<count($items);$i++){

          $quoteId = $items[$i]['item_id'];
          $quote = $objectManager->create('MagentoQuoteModelQuoteItem')->load($quoteId);
          $productId = $quote->getProductId();
          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productFlavours = $product->getResource()->getAttribute('flavors')->getFrontend()->getValue($product);
          if($productFlavours == 'No' || $productFlavours == 'NA'){
          $productFlavours = '';
          }
          $items[$i]['flavor'] = $productFlavours;
          }
          $result['totalsData']['items'] = $items;
          return $result;
          }

          }


          details.html



          Copy vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html in theme and add



          <div class="product-item-flavor" data-bind="text: $parent.flavor"></div>


          below



          <strong class="product-item-name" data-bind="text: $parent.name"></strong>


          That's it!
          Hope it helps!






          share|improve this answer
























          • did the same but not working.

            – Sarfaraj
            Dec 20 '17 at 6:02











          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%2f162999%2fgetting-the-custom-product-attribute-in-the-checkout-summary-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









          0














          You will have to create a plugin for that. I wanted to add product flavor to order summary. This is the way I created a plugin and achieved what I wanted.



          Vendor = Sejal



          Files you need to create:




          1. Registration.php : appcodeSejalFlavorregistration.php

          2. di.xml : appcodeSejalFlavoretcdi.xml

          3. module.xml : appcodeSejalFlavoretcdi.xml

          4. ConfigProviderPlugin.php : appcodeSejalFlavorPluginConfigProviderPlugin.php

          5. details.html : copy of vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html


          you can override this file in your theme like this



          appdesignfrontendVendorthemenameMagento_Checkoutwebtemplatesummaryitemdetails.html



          Code:
          registration.php



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE,
          'Sejal_Flavor',
          __DIR__
          );


          di.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCheckoutModelDefaultConfigProvider">
          <plugin name="AddAttPlug" type="SejalFlavorPluginConfigProviderPlugin" />
          </type>
          </config>


          module.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
          <module name="Sejal_Flavor" setup_version="1.0.0">
          </module>
          </config>


          ConfigProviderPlugin.php



          <?php

          namespace SejalFlavorPlugin;

          class ConfigProviderPlugin extends MagentoFrameworkModelAbstractModel
          {

          public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, array $result)
          {

          $items = $result['totalsData']['items'];

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          for($i=0;$i<count($items);$i++){

          $quoteId = $items[$i]['item_id'];
          $quote = $objectManager->create('MagentoQuoteModelQuoteItem')->load($quoteId);
          $productId = $quote->getProductId();
          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productFlavours = $product->getResource()->getAttribute('flavors')->getFrontend()->getValue($product);
          if($productFlavours == 'No' || $productFlavours == 'NA'){
          $productFlavours = '';
          }
          $items[$i]['flavor'] = $productFlavours;
          }
          $result['totalsData']['items'] = $items;
          return $result;
          }

          }


          details.html



          Copy vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html in theme and add



          <div class="product-item-flavor" data-bind="text: $parent.flavor"></div>


          below



          <strong class="product-item-name" data-bind="text: $parent.name"></strong>


          That's it!
          Hope it helps!






          share|improve this answer
























          • did the same but not working.

            – Sarfaraj
            Dec 20 '17 at 6:02
















          0














          You will have to create a plugin for that. I wanted to add product flavor to order summary. This is the way I created a plugin and achieved what I wanted.



          Vendor = Sejal



          Files you need to create:




          1. Registration.php : appcodeSejalFlavorregistration.php

          2. di.xml : appcodeSejalFlavoretcdi.xml

          3. module.xml : appcodeSejalFlavoretcdi.xml

          4. ConfigProviderPlugin.php : appcodeSejalFlavorPluginConfigProviderPlugin.php

          5. details.html : copy of vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html


          you can override this file in your theme like this



          appdesignfrontendVendorthemenameMagento_Checkoutwebtemplatesummaryitemdetails.html



          Code:
          registration.php



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE,
          'Sejal_Flavor',
          __DIR__
          );


          di.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCheckoutModelDefaultConfigProvider">
          <plugin name="AddAttPlug" type="SejalFlavorPluginConfigProviderPlugin" />
          </type>
          </config>


          module.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
          <module name="Sejal_Flavor" setup_version="1.0.0">
          </module>
          </config>


          ConfigProviderPlugin.php



          <?php

          namespace SejalFlavorPlugin;

          class ConfigProviderPlugin extends MagentoFrameworkModelAbstractModel
          {

          public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, array $result)
          {

          $items = $result['totalsData']['items'];

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          for($i=0;$i<count($items);$i++){

          $quoteId = $items[$i]['item_id'];
          $quote = $objectManager->create('MagentoQuoteModelQuoteItem')->load($quoteId);
          $productId = $quote->getProductId();
          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productFlavours = $product->getResource()->getAttribute('flavors')->getFrontend()->getValue($product);
          if($productFlavours == 'No' || $productFlavours == 'NA'){
          $productFlavours = '';
          }
          $items[$i]['flavor'] = $productFlavours;
          }
          $result['totalsData']['items'] = $items;
          return $result;
          }

          }


          details.html



          Copy vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html in theme and add



          <div class="product-item-flavor" data-bind="text: $parent.flavor"></div>


          below



          <strong class="product-item-name" data-bind="text: $parent.name"></strong>


          That's it!
          Hope it helps!






          share|improve this answer
























          • did the same but not working.

            – Sarfaraj
            Dec 20 '17 at 6:02














          0












          0








          0







          You will have to create a plugin for that. I wanted to add product flavor to order summary. This is the way I created a plugin and achieved what I wanted.



          Vendor = Sejal



          Files you need to create:




          1. Registration.php : appcodeSejalFlavorregistration.php

          2. di.xml : appcodeSejalFlavoretcdi.xml

          3. module.xml : appcodeSejalFlavoretcdi.xml

          4. ConfigProviderPlugin.php : appcodeSejalFlavorPluginConfigProviderPlugin.php

          5. details.html : copy of vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html


          you can override this file in your theme like this



          appdesignfrontendVendorthemenameMagento_Checkoutwebtemplatesummaryitemdetails.html



          Code:
          registration.php



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE,
          'Sejal_Flavor',
          __DIR__
          );


          di.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCheckoutModelDefaultConfigProvider">
          <plugin name="AddAttPlug" type="SejalFlavorPluginConfigProviderPlugin" />
          </type>
          </config>


          module.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
          <module name="Sejal_Flavor" setup_version="1.0.0">
          </module>
          </config>


          ConfigProviderPlugin.php



          <?php

          namespace SejalFlavorPlugin;

          class ConfigProviderPlugin extends MagentoFrameworkModelAbstractModel
          {

          public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, array $result)
          {

          $items = $result['totalsData']['items'];

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          for($i=0;$i<count($items);$i++){

          $quoteId = $items[$i]['item_id'];
          $quote = $objectManager->create('MagentoQuoteModelQuoteItem')->load($quoteId);
          $productId = $quote->getProductId();
          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productFlavours = $product->getResource()->getAttribute('flavors')->getFrontend()->getValue($product);
          if($productFlavours == 'No' || $productFlavours == 'NA'){
          $productFlavours = '';
          }
          $items[$i]['flavor'] = $productFlavours;
          }
          $result['totalsData']['items'] = $items;
          return $result;
          }

          }


          details.html



          Copy vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html in theme and add



          <div class="product-item-flavor" data-bind="text: $parent.flavor"></div>


          below



          <strong class="product-item-name" data-bind="text: $parent.name"></strong>


          That's it!
          Hope it helps!






          share|improve this answer













          You will have to create a plugin for that. I wanted to add product flavor to order summary. This is the way I created a plugin and achieved what I wanted.



          Vendor = Sejal



          Files you need to create:




          1. Registration.php : appcodeSejalFlavorregistration.php

          2. di.xml : appcodeSejalFlavoretcdi.xml

          3. module.xml : appcodeSejalFlavoretcdi.xml

          4. ConfigProviderPlugin.php : appcodeSejalFlavorPluginConfigProviderPlugin.php

          5. details.html : copy of vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html


          you can override this file in your theme like this



          appdesignfrontendVendorthemenameMagento_Checkoutwebtemplatesummaryitemdetails.html



          Code:
          registration.php



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE,
          'Sejal_Flavor',
          __DIR__
          );


          di.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCheckoutModelDefaultConfigProvider">
          <plugin name="AddAttPlug" type="SejalFlavorPluginConfigProviderPlugin" />
          </type>
          </config>


          module.xml



          <?xml version="1.0"?>

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
          <module name="Sejal_Flavor" setup_version="1.0.0">
          </module>
          </config>


          ConfigProviderPlugin.php



          <?php

          namespace SejalFlavorPlugin;

          class ConfigProviderPlugin extends MagentoFrameworkModelAbstractModel
          {

          public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, array $result)
          {

          $items = $result['totalsData']['items'];

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          for($i=0;$i<count($items);$i++){

          $quoteId = $items[$i]['item_id'];
          $quote = $objectManager->create('MagentoQuoteModelQuoteItem')->load($quoteId);
          $productId = $quote->getProductId();
          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productFlavours = $product->getResource()->getAttribute('flavors')->getFrontend()->getValue($product);
          if($productFlavours == 'No' || $productFlavours == 'NA'){
          $productFlavours = '';
          }
          $items[$i]['flavor'] = $productFlavours;
          }
          $result['totalsData']['items'] = $items;
          return $result;
          }

          }


          details.html



          Copy vendormagentomodule-checkoutviewfrontendwebtemplatesummaryitemdetails.html in theme and add



          <div class="product-item-flavor" data-bind="text: $parent.flavor"></div>


          below



          <strong class="product-item-name" data-bind="text: $parent.name"></strong>


          That's it!
          Hope it helps!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 10 '17 at 15:58









          Sejal ShahSejal Shah

          1,021421




          1,021421













          • did the same but not working.

            – Sarfaraj
            Dec 20 '17 at 6:02



















          • did the same but not working.

            – Sarfaraj
            Dec 20 '17 at 6:02

















          did the same but not working.

          – Sarfaraj
          Dec 20 '17 at 6:02





          did the same but not working.

          – Sarfaraj
          Dec 20 '17 at 6:02


















          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%2f162999%2fgetting-the-custom-product-attribute-in-the-checkout-summary-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

          what is the purpose of having a “thru cal” on RF PCB?

          What does Gandalf whisper to the Moth on the Orthanc in Isengard?

          magento2 creating a lot of catalogrule_product_temp tables