Microsoft Dynamics 365 Commerce is an evolution of Dynamics 365 Retail, which launched with new and improved capabilities for e-commerce, content management. To begin development and extension on Dynamics 365 eCommerce we'll need to install the following tools on the development machine:
- VSCODE - https://code.visualstudio.com
- Node.js - https://nodejs.org (Currently version 10.x is the main supported version and the MSI installer can be found here:https://nodejs.org/dist/latest-v10.x/ )
- Yarn - https://legacy.yarnpkg.com
Create a folder in your local drive to hold the e-Commerce site code - 'C:\repos'
Open CMD in administrator mode and go to the folder directory you just created and clone the Microsoft eCommerce repository with the following command:
git clone https://github.com/microsoft/Msdyn365.Commerce.Online.gitThis may take a while. Next, go inside the newly created folder C:\repos\Msdyn365.Commerce.Online' and run 'yarn' to resolve conflicts and get latest dependency packages:
This command can take several minutes to run. Once complete you should see something similar to the following screenshot:
(Note: if you get “would clobber existing tag” warnings ,run “yarn cache clean”)
Once this has been resolved, open 'C:\repos\Msdyn365.Commerce.Online\node_modules\@msdyn365-commerce-modules' in file explorer to view Microsoft's standard modules that come with the package.
To begin development, Open the 'Msdyn365.Commerce.Online' folder in VS Code. Ensure that your CMD is running in administrator mode and it's file directory should be pointing to 'Msdyn365.Commerce.Online' , i.e 'C:\repos\Msdyn365.Commerce.Online'
Creating modules
To add a new module, run ‘yarn msdyn365 add-module MODULE_NAME’ command. For example, the following command creates a module that is named ‘yourmodulename’:
yarn msdyn365 add-module yourmodulename
or to clone a standard module :
yarn msdyn365 standardmodulename yourmodulename
e.g yarn msdyn365 clone text-block mytextblock
- yourmodulename.definition.json: This file is referred to as the module definition file which is used to register the module and provides metadata to the site builder tool including the module name, description and category.
- yourmodulename.data.ts: This data.ts file contains the typing's for data actions that are used by the module to fetch data. Once a data action gets its data it is stored in the properties in this file.You can point your local dev environment to the retail server to load data from the server directly during development through the .env file.Here you will set the retail server link and env details, you can follow the extensibility guide to get this values from the back office and set it here (The .env file configuration is discussed later). Once the .env file is configured, you can configure your development site data to be loaded by calling the action methods from this data file. The action method will make the API call and get the data.You can also set mock data for the development env in the mock data file.
- yourmodulename.tsx: This file is a React component that controls the module’s view model and calls the module view. You’ll find a React “render()” method with some default embedded HTML.
- yourmodulename.view.tsx: This file is the component that controls the module’s view. Additional module views can be provided in various themes to render a module differently depending on the requirements of the theme.
- mocks/yourmodulename.json: This json file under the “mocks” directory is used to configure mock data for your module to be tested locally. When modules are run on a production server this data comes from the Dynamics CMS database as configured by the page authors instead of the mock file.
- yourmodulename.props.autogenerated.ts : This file is an auto generated typescript file that should not be manually touched. Adding new configuration values to your module definition file and saving the file will automatically rebuild this file with appropriate interfaces. The interfaces in here can be accessed via the module view and react files as needed
The allocated port number is 4000 by default. You may configure the port number in the .env file. To add more designs and contents to the module, you may refer to the ‘Designing our Module’ section of the ‘Dynamics 365 Commerce Online Developer Extensibility Getting Started Guide’ and follow Microsoft documentation on module creation at:
https://docs.microsoft.com/en-us/dynamics365/commerce/e-commerce-extensibility/create-new-module
Additional Notes
Configure development environment (.env) file
The. env is a simple configuration text file that is provided as part of the Dynamics 365 Commerce online software development kit (SDK). It defines the set of variables and data sources that can be used by the Node app that runs on the development environment. You may follow the following Microsoft documentation to configure the .env file and point to specific server/environment to retrieve and load data from:
https://docs.microsoft.com/en-us/dynamics365/commerce/e-commerce-extensibility/configure-env-file
Insightful.
ReplyDelete