web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Unanswered

How to get product details using product code or product id and add it into cart in d365 commerce module development

(0) ShareShare
ReportReport
Posted on by 85

Hi Guys,

I am new in d365 commerce and react js, I am trying to pull product details using product code, i have created control for upload excel file by creating custom module and using excel will get product codes and quantity, i am trying to get product details using this product codes but i am not able use existing data actions like get-full-products, get-full-products-by-refine-search-text and get-simple-products but not able to fetch it.

Below is my code for excel upload control : 

import { CSVReader } from 'react-papaparse';
import { IProductQuickorderData } from './product-quickorder.data';
import { IProductQuickorderProps } from './product-quickorder.props.autogenerated';
// import {getScanResult, GetScanResultInput} from '@msdyn365-commerce-modules/retail-actions';
// import classnames from 'classnames';
// import { debounce } from 'lodash';
import { observable } from 'mobx';
import React from 'react';

// import getSimpleProducts from '@msdyn365-commerce-modules/retail-actions';



// export interface IProductQuickorderViewProps extends IProductQuickorderProps<IProductQuickorderData> {}



/**
 *
 * ProductQuickorder component
 * @extends {React.PureComponent<IProductQuickorderProps<IProductQuickorderData>>}
 */
class ProductQuickorder extends React.PureComponent<IProductQuickorderProps<IProductQuickorderData>>{
  @observable
  //  private cancellabelDebounce: debounce;
 
  //  private readonly waitTime: number = 500;
 
  handleOnDrop = (data: object) => {debugger;
  //   if (this.cancellabelDebounce) {
  //     // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call -- existing code.
  //     this.cancellabelDebounce.cancel();
  // }
    //   const {
    //     // telemetry,
    //     context
    // } = this.props;

    console.log('---------------------------');
    console.log(data);
    console.log('---------------------------');
      if(typeof data !='undefined')
      {
        for(var i=1;i<data.length;i++)
        {

       
          const query =data[i].data[0];
          // const product = getSimpleProducts;
          // product.getProductList(query,this.props);
    //     this.cancellabelDebounce = debounce(() => {
    //       getScanResult(
    //           new GetScanResultInput(
    //               context.actionContext.requestContext.apiSettings,
    //               query,
    //               context.actionContext.requestContext.apiSettings.channelId
    //           ),
    //           this.props.context.actionContext)
    //           .then(results => {debugger;
    //               this.setState({
    //                   productResponse: results?.Product,
    //                   productDimensions: results?.ProductDimensionFull,
    //                   isQuickOrderFormExpanded: true
    //               });
    //           })
    //           .catch(error => {debugger;
    //               this.setState({ productText: '' });
    //               telemetry.exception(error);
    //               telemetry.debug('Unable to get scan results');
    //           });
    //   }, this.waitTime);
         

       }
     }

    // setTimeout(() => {
    //     // eslint-disable-next-line @typescript-eslint/no-unsafe-call -- Existing code.
    //     this.cancellabelDebounce();
    // }, 0);
  //  return(
  //     <div>
  //     {data }
  //     </div>
     
  //   );
  }
      handleOnFileLoad = (data: any) => {debugger;
        console.log('---------------------------');
        console.log(data);
        console.log('---------------------------');
      }

    public render(): JSX.Element {debugger;
        return (
          <div>
          <CSVReader
          onDrop={this.handleOnDrop}
          // onFileLoad={this.handleOnFileLoad}
          onError={this.handleOnError}
          addRemoveButton
          // removeButtonColor='#659cef'
          onRemoveFile={this.handleOnRemoveFile}
        >
          <span>Drop CSV file here or click to upload.</span>
        </CSVReader>
         {/* <div className="board-row">{this.getProductsData()}</div> */}
         </div>
          );
    }

    handleOnError = (err: any, file: any, inputElem: any, reason: any) => {debugger;
        console.log(err);
      }

      handleOnRemoveFile = (data: any) => {debugger;
        console.log('---------------------------')
        console.log(data)
        console.log('---------------------------')
      }
   
 
}




export default ProductQuickorder;
Output of this code is : 
pastedimage1639548482281v2.png

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Reply,

    I will research and feed you back.

  • Ax developer Profile Picture
    85 on at

    Thanks Will, also if you know related to this question can you help me to answer this too:

    https://stackoverflow.com/questions/70353481/how-to-add-custom-module-into-d365-commerce-buybox-module

    I want to add this same custom module into buybox module of product details but i am not able to see it on page.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 298 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 179 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 121 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans