项目作者: plewandowski

项目描述 :
Magento 2 currency exchange calculator module for training purposes
高级语言: PHP
项目地址: git://github.com/plewandowski/m2-currency-exchange-calculator.git


Magento 2 currency exchange calculator

This is Magento 2 currency exchange calculator project build for training purposes. It demonstrated how to wrap external API in Magento API and consume it with JS widget.
It’s simplified example. In production ready module some improvements would be recommended such of:

  • external api response caching or keeping records in db table updated by regular cron job for performance and availability reasons
  • better module configuration

Installation

add following json to composer.json

  1. {
  2. "require": {
  3. "plewandowski/currency-exchange-calculator": "*"
  4. }
  5. ...
  6. "repositories": [
  7. {
  8. "type": "vcs",
  9. "url": "https://github.com/plewandowski/m2-currency-exchange-calculator"
  10. }
  11. ]
  12. }

then

  1. composer update

How it works in general?

  1. Calculator block is added in footer via layout xml
  2. Calculator frontend logic is a jQuery magento widget is initialized via data-mage-init
  3. The widget callas M2 custom REST api resources to fetch actual currency rate
  4. M2 REST api calls third-party (currentyl NBP API) underhood

Validation is done using magento validation componenet