SlideShare a Scribd company logo
1 of 18
Magento NodeJS
Microservices
Magento
Meetup
Kharkiv
#11
Magento
Meetup
Kharkiv
#11
Magento Developer 8+ years
Magento Microservices:
- NodeJS microservices -> NodeJento <-
- Python microservice -> PyGento
- Laravel Eloquent PHP -> Laragento
Magento PWA in 15 minutes
Magento SaaS
Linkedin:https://www.linkedin.com/in/yehorshytikov/
GitHub: https://github.com/Genaker/
Hobby: Sailing
Magento
Meetup
Kharkiv
#11
Resolving Magento issues
● Slow performance for non cached pages and
dynamic content
● Ajax Requests Performance Issue
● App bootstrap issue
● Scaling issues
● GraphQL performance issue
● Blocking I/O, HTTP, MySQL
● Deployment issues
● 6000+ reported GitHub bugs
● High Entry Level
● Slow development time
● Difficult to debug
● Legacy monolithic framework codebase
● Outdated technologies: Zend Framework 1,
KnockoutJS, old fashioned custom build ORM.
Magento
Meetup
Kharkiv
#11
Why NodeJS?
● It has Non-blocking I/O API
● It runs on the Single thread
● The same tech stack on the frontend and backend
● Node.js handles multiple requests
● Easy to install
● Fast, Google V8 engine used in Chrome and in Node.js
● The performance of Node.js is faster as compared to
PHP
● It possesses a rich community of developers
● NPM packet manager
● One language for Frontend and Backend and Desktop
● High salary
Magento
Meetup
Kharkiv
#11
How Node.js Has Impacted Your Business
Text
2018 Node.js User Survey Report
Magento
Meetup
Kharkiv
#11
Magento 2 Microservices
Instead of containing everything in a single monolithic codebase, the microservices-
based application is broken down into smaller, lightweight pieces based on a logical
construct. The application consists of independent small (micro-) services/extensions and
when we deploy or scale the app, individual services get distributed independently from
the monolith.
Magento
Meetup
Kharkiv
#11
Famous Microservices for Magento
Magento
Meetup
Kharkiv
#11
Magento Strangler Pattern
Adobe: “In our case "Strangler pattern" was introduced on the level of a stand-alone
Node.js-based GraphQL server. Also, it gave us the possibility to develop services
from scratch not affecting monolith anyhow and not being burdened with PHP BiC
guidelines.”
Strangler Pattern is a way of migrating a legacy system incrementally by replacing
existing functionalities with new applications and services in a phased approach. After
the replacement of the entire functionality the new application system eventually replaces
all the old legacy system's features. The name "strangler pattern" was inspired from
strangler fig trees.
The strangler application consists of two types of services. First, there are services that
implement functionality that previously resided in the monolith. Second, there are
services that implement new features. The latter are particularly useful since they
demonstrate to the business the value of using microservices.
Magento
Meetup
Kharkiv
#11
Magento Strangler Pattern
Magento
Meetup
Kharkiv
#11
Shared-database-per-microservices-and-
monolith pattern
The same database is shared by several microservices and monolith. You need to
carefully assess the application architecture before adopting this pattern, and make sure
that you avoid hot tables (single tables that are shared among multiple microservices). All
your database changes must also be backward-compatible; for example, developers can
drop columns or tables only if objects are not referenced by the current and previous
versions of all microservices.
Magento
Meetup
Kharkiv
#11
Let’s start
Magento
Meetup
Kharkiv
#11
NodeJS + ExpressJS
npm install express
npm install nodemon
app.js:
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
nodemon app.js or node app.js
nodemon is a tool that helps develop node.js based applications by
automatically restarting the node application when file changes in the
directory are detecte
Magento
Meetup
Kharkiv
#11
What is NodeJento?
NodeJS implementation of the Magento 2 ORM on top of Sequelize
If you want to Sequelize to connect to a Magento database that is already
filled with tables and data NodeJento excised database directly without
invocation of the Magento 2 PHP framework, so we won’t have to write any
MySQL queries.
https://github.com/Genaker/nodejento
Magento
Meetup
Kharkiv
#11
NodeJento Initialisation
npm install https://github.com/Genaker/nodejento
const { Sequelize } = require('sequelize');
var magentoModels = require("nodejento/Models/init-models");
const sequelize = new Sequelize(
'magento','root','password',
{
host: '127.0.0.1',
dialect: 'mysql',
freezeTableName: true
});
const models = magentoModels.initModels(sequelize);
//express router
app.get('/nodejento', async (req, res) => {
let Product = await models.CatalogProductEntity.findOne({ where: {'sku':
'24-MB01'}});
res.send(Product.toJSON())
})
Magento
Meetup
Kharkiv
#11
Eager EAV Attributes Loading
let Product = await models.CatalogProductEntity.findAll({
where: {'sku': ['24-MB01', '24-MB04', '24-WG084', '24-WG085']},
include: [
{ model: models.CatalogProductEntityVarchar, as:
'CatalogProductEntityVarchars', where:{attribute_id: VisibleOnFront,
store_id: [0,1]}, required: false, attributes:['store_id',
'value','attribute_id'], separate: true},
{ model: models.CatalogProductEntityInt, as:
'CatalogProductEntityInts', where:{attribute_id: VisibleOnFront,
store_id: [0,1]}, required: false, attributes:['store_id',
'value','attribute_id'], separate: true},
{ model: models.CatalogProductEntityText, as:
'CatalogProductEntityTexts', where:{attribute_id: VisibleOnFront,
store_id: [0,1]}, required: false, attributes:['store_id',
'value','attribute_id'], separate: true},
{ model: models.CatalogProductEntityDecimal, as:
'CatalogProductEntityDecimals', where:{attribute_id: VisibleOnFront,
store_id: [0,1]}, required: false, attributes:['store_id',
'value','attribute_id'], separate: true},
{ model: models.CatalogProductEntityDatetime, as:
'CatalogProductEntityDatetimes', where:{attribute_id: VisibleOnFront,
store_id: [0,1]}, required: false, attributes:['store_id',
'value','attribute_id'], separate: true},
]
});
Magento
Meetup
Kharkiv
#11
Result Output:
curl http://localhost:3000/nodejento
{ "result": [
{
"entity_id": 57,
"attribute_set_id": 15,
"type_id": "simple",
"sku": "24-MB01",
"has_options": 0,
"required_options": 0,
"created_at": "2021-10-11T17:10:09.000Z",
"updated_at": "2021-10-11T17:10:09.000Z",
"attributes": {
"name": {
"value": "Joust Duffle Bag",
"frontend_input": "text"
},
"image": {
"value": "/m/b/mb01-blue-0.jpg",
"frontend_input": "media_image"
},
"small_image": {
"value": "/m/b/mb01-blue-0.jpg",
"frontend_input": "media_image" ....
Magento
Meetup
Kharkiv
#11
Live Coding Session
Thank you for attention

More Related Content

Similar to Magento NodeJS Microservices — Yegor Shytikov | Magento Meetup Online #11

Node.js and the MEAN Stack Building Full-Stack Web Applications.pdf
Node.js and the MEAN Stack Building Full-Stack Web Applications.pdfNode.js and the MEAN Stack Building Full-Stack Web Applications.pdf
Node.js and the MEAN Stack Building Full-Stack Web Applications.pdf
lubnayasminsebl
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
Rob Davarnia
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
Edureka!
 

Similar to Magento NodeJS Microservices — Yegor Shytikov | Magento Meetup Online #11 (20)

Node js
Node jsNode js
Node js
 
Node.js and the MEAN Stack Building Full-Stack Web Applications.pdf
Node.js and the MEAN Stack Building Full-Stack Web Applications.pdfNode.js and the MEAN Stack Building Full-Stack Web Applications.pdf
Node.js and the MEAN Stack Building Full-Stack Web Applications.pdf
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
 
Front end microservices - October 2019
Front end microservices - October 2019Front end microservices - October 2019
Front end microservices - October 2019
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
 
Vitaliy Kryvonos_CV_up
Vitaliy Kryvonos_CV_upVitaliy Kryvonos_CV_up
Vitaliy Kryvonos_CV_up
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
 
How create react app help in creating a new react applications
How create react app help in creating a new react applications How create react app help in creating a new react applications
How create react app help in creating a new react applications
 
Кирилл Толкачев. Микросервисы: огонь, вода и девопс
Кирилл Толкачев. Микросервисы: огонь, вода и девопсКирилл Толкачев. Микросервисы: огонь, вода и девопс
Кирилл Толкачев. Микросервисы: огонь, вода и девопс
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
 
PWA - The Future of eCommerce - Magento Meetup Ahmedabad 2018
PWA - The Future of eCommerce - Magento Meetup Ahmedabad 2018PWA - The Future of eCommerce - Magento Meetup Ahmedabad 2018
PWA - The Future of eCommerce - Magento Meetup Ahmedabad 2018
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 

More from Magecom UK Limited

More from Magecom UK Limited (20)

Magento Meetup #12. Alex Shkurko.pptx
Magento Meetup #12. Alex Shkurko.pptxMagento Meetup #12. Alex Shkurko.pptx
Magento Meetup #12. Alex Shkurko.pptx
 
Magento Meetup #12 Anastasiia Bondar
Magento Meetup #12 Anastasiia BondarMagento Meetup #12 Anastasiia Bondar
Magento Meetup #12 Anastasiia Bondar
 
Magento Meetup #12 Vlad Opukhlyi
Magento Meetup #12 Vlad OpukhlyiMagento Meetup #12 Vlad Opukhlyi
Magento Meetup #12 Vlad Opukhlyi
 
Google Page Insights and Magento 2 — Sergey Nezbritskiy | Magento Meetup Onli...
Google Page Insights and Magento 2 — Sergey Nezbritskiy | Magento Meetup Onli...Google Page Insights and Magento 2 — Sergey Nezbritskiy | Magento Meetup Onli...
Google Page Insights and Magento 2 — Sergey Nezbritskiy | Magento Meetup Onli...
 
Magento enhanced media gallery - Alexander Shkurko
Magento enhanced media gallery - Alexander ShkurkoMagento enhanced media gallery - Alexander Shkurko
Magento enhanced media gallery - Alexander Shkurko
 
7 ошибок одного Black Friday - Влад Опухлый
7 ошибок одного Black Friday - Влад Опухлый7 ошибок одного Black Friday - Влад Опухлый
7 ошибок одного Black Friday - Влад Опухлый
 
Magento & Cloud - Korostelov Avexey
Magento & Cloud - Korostelov AvexeyMagento & Cloud - Korostelov Avexey
Magento & Cloud - Korostelov Avexey
 
Making the Magento 2 Javascript Loading Great Again - Robin van Raan
Making the Magento 2 Javascript Loading Great Again - Robin van RaanMaking the Magento 2 Javascript Loading Great Again - Robin van Raan
Making the Magento 2 Javascript Loading Great Again - Robin van Raan
 
Deep Dive in Magento DI
Deep Dive in Magento DIDeep Dive in Magento DI
Deep Dive in Magento DI
 
From Repositories to Commands - Alexander Shkurko
From Repositories to Commands - Alexander Shkurko From Repositories to Commands - Alexander Shkurko
From Repositories to Commands - Alexander Shkurko
 
Advanced GIT or How to Change the History
Advanced GIT  or How to Change the HistoryAdvanced GIT  or How to Change the History
Advanced GIT or How to Change the History
 
MSI In-Store Pickup Функционал & сложности
MSI In-Store Pickup Функционал & сложностиMSI In-Store Pickup Функционал & сложности
MSI In-Store Pickup Функционал & сложности
 
Adobe Stock Integration community project
Adobe Stock Integration community projectAdobe Stock Integration community project
Adobe Stock Integration community project
 
Proof of Concept for Magento 2 Projects: Occamo’s Razor
Proof of Concept for Magento 2 Projects: Occamo’s RazorProof of Concept for Magento 2 Projects: Occamo’s Razor
Proof of Concept for Magento 2 Projects: Occamo’s Razor
 
Что нужно знать девелоперу о SEO на этапе проектирования сайта
Что нужно знать девелоперу о SEO на этапе проектирования сайтаЧто нужно знать девелоперу о SEO на этапе проектирования сайта
Что нужно знать девелоперу о SEO на этапе проектирования сайта
 
Magento-сертификация: инструкция по применению и как это было
Magento-сертификация: инструкция по применению и как это былоMagento-сертификация: инструкция по применению и как это было
Magento-сертификация: инструкция по применению и как это было
 
Experience in Magento Community Projects
Experience in Magento Community ProjectsExperience in Magento Community Projects
Experience in Magento Community Projects
 
UI components: synergy of backend and frontend
UI components: synergy of backend and frontendUI components: synergy of backend and frontend
UI components: synergy of backend and frontend
 
MSI - Reservation Challenges with 3rd-party Systems
MSI - Reservation Challenges with 3rd-party SystemsMSI - Reservation Challenges with 3rd-party Systems
MSI - Reservation Challenges with 3rd-party Systems
 
Business wants what?!
Business wants what?!Business wants what?!
Business wants what?!
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Magento NodeJS Microservices — Yegor Shytikov | Magento Meetup Online #11

  • 2. Magento Meetup Kharkiv #11 Magento Developer 8+ years Magento Microservices: - NodeJS microservices -> NodeJento <- - Python microservice -> PyGento - Laravel Eloquent PHP -> Laragento Magento PWA in 15 minutes Magento SaaS Linkedin:https://www.linkedin.com/in/yehorshytikov/ GitHub: https://github.com/Genaker/ Hobby: Sailing
  • 3. Magento Meetup Kharkiv #11 Resolving Magento issues ● Slow performance for non cached pages and dynamic content ● Ajax Requests Performance Issue ● App bootstrap issue ● Scaling issues ● GraphQL performance issue ● Blocking I/O, HTTP, MySQL ● Deployment issues ● 6000+ reported GitHub bugs ● High Entry Level ● Slow development time ● Difficult to debug ● Legacy monolithic framework codebase ● Outdated technologies: Zend Framework 1, KnockoutJS, old fashioned custom build ORM.
  • 4. Magento Meetup Kharkiv #11 Why NodeJS? ● It has Non-blocking I/O API ● It runs on the Single thread ● The same tech stack on the frontend and backend ● Node.js handles multiple requests ● Easy to install ● Fast, Google V8 engine used in Chrome and in Node.js ● The performance of Node.js is faster as compared to PHP ● It possesses a rich community of developers ● NPM packet manager ● One language for Frontend and Backend and Desktop ● High salary
  • 5. Magento Meetup Kharkiv #11 How Node.js Has Impacted Your Business Text 2018 Node.js User Survey Report
  • 6. Magento Meetup Kharkiv #11 Magento 2 Microservices Instead of containing everything in a single monolithic codebase, the microservices- based application is broken down into smaller, lightweight pieces based on a logical construct. The application consists of independent small (micro-) services/extensions and when we deploy or scale the app, individual services get distributed independently from the monolith.
  • 8. Magento Meetup Kharkiv #11 Magento Strangler Pattern Adobe: “In our case "Strangler pattern" was introduced on the level of a stand-alone Node.js-based GraphQL server. Also, it gave us the possibility to develop services from scratch not affecting monolith anyhow and not being burdened with PHP BiC guidelines.” Strangler Pattern is a way of migrating a legacy system incrementally by replacing existing functionalities with new applications and services in a phased approach. After the replacement of the entire functionality the new application system eventually replaces all the old legacy system's features. The name "strangler pattern" was inspired from strangler fig trees. The strangler application consists of two types of services. First, there are services that implement functionality that previously resided in the monolith. Second, there are services that implement new features. The latter are particularly useful since they demonstrate to the business the value of using microservices.
  • 10. Magento Meetup Kharkiv #11 Shared-database-per-microservices-and- monolith pattern The same database is shared by several microservices and monolith. You need to carefully assess the application architecture before adopting this pattern, and make sure that you avoid hot tables (single tables that are shared among multiple microservices). All your database changes must also be backward-compatible; for example, developers can drop columns or tables only if objects are not referenced by the current and previous versions of all microservices.
  • 12. Magento Meetup Kharkiv #11 NodeJS + ExpressJS npm install express npm install nodemon app.js: const express = require('express') const app = express() const port = 3000 app.get('/', (req, res) => { res.send('Hello World!') }) app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) }) nodemon app.js or node app.js nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detecte
  • 13. Magento Meetup Kharkiv #11 What is NodeJento? NodeJS implementation of the Magento 2 ORM on top of Sequelize If you want to Sequelize to connect to a Magento database that is already filled with tables and data NodeJento excised database directly without invocation of the Magento 2 PHP framework, so we won’t have to write any MySQL queries. https://github.com/Genaker/nodejento
  • 14. Magento Meetup Kharkiv #11 NodeJento Initialisation npm install https://github.com/Genaker/nodejento const { Sequelize } = require('sequelize'); var magentoModels = require("nodejento/Models/init-models"); const sequelize = new Sequelize( 'magento','root','password', { host: '127.0.0.1', dialect: 'mysql', freezeTableName: true }); const models = magentoModels.initModels(sequelize); //express router app.get('/nodejento', async (req, res) => { let Product = await models.CatalogProductEntity.findOne({ where: {'sku': '24-MB01'}}); res.send(Product.toJSON()) })
  • 15. Magento Meetup Kharkiv #11 Eager EAV Attributes Loading let Product = await models.CatalogProductEntity.findAll({ where: {'sku': ['24-MB01', '24-MB04', '24-WG084', '24-WG085']}, include: [ { model: models.CatalogProductEntityVarchar, as: 'CatalogProductEntityVarchars', where:{attribute_id: VisibleOnFront, store_id: [0,1]}, required: false, attributes:['store_id', 'value','attribute_id'], separate: true}, { model: models.CatalogProductEntityInt, as: 'CatalogProductEntityInts', where:{attribute_id: VisibleOnFront, store_id: [0,1]}, required: false, attributes:['store_id', 'value','attribute_id'], separate: true}, { model: models.CatalogProductEntityText, as: 'CatalogProductEntityTexts', where:{attribute_id: VisibleOnFront, store_id: [0,1]}, required: false, attributes:['store_id', 'value','attribute_id'], separate: true}, { model: models.CatalogProductEntityDecimal, as: 'CatalogProductEntityDecimals', where:{attribute_id: VisibleOnFront, store_id: [0,1]}, required: false, attributes:['store_id', 'value','attribute_id'], separate: true}, { model: models.CatalogProductEntityDatetime, as: 'CatalogProductEntityDatetimes', where:{attribute_id: VisibleOnFront, store_id: [0,1]}, required: false, attributes:['store_id', 'value','attribute_id'], separate: true}, ] });
  • 16. Magento Meetup Kharkiv #11 Result Output: curl http://localhost:3000/nodejento { "result": [ { "entity_id": 57, "attribute_set_id": 15, "type_id": "simple", "sku": "24-MB01", "has_options": 0, "required_options": 0, "created_at": "2021-10-11T17:10:09.000Z", "updated_at": "2021-10-11T17:10:09.000Z", "attributes": { "name": { "value": "Joust Duffle Bag", "frontend_input": "text" }, "image": { "value": "/m/b/mb01-blue-0.jpg", "frontend_input": "media_image" }, "small_image": { "value": "/m/b/mb01-blue-0.jpg", "frontend_input": "media_image" ....
  • 18. Thank you for attention