SlideShare une entreprise Scribd logo
1  sur  74
Télécharger pour lire hors ligne
Single Page
Shops
With Magento
And AngularJS
Who am I?
Vinai
How did I get here?
Freelance again!
I want to write a book...
...about Magento
(one trick pony)
Iʹll Self Publish!
...on Magento
Work, Lots!
Fun Stuff
Coding
Money
Unfun Stuff
Settings
Theming
Email Templates
Terms & Conditions
Support
MORE FUN
WoW
Much
Different
So faster
News Learnin
Very
Angular
Such JS
So Modern
WoW
JavaScript MVC Toolkit
DI and Testability are at its
very core
Clean separation of MVC
layers
Many pre‑made Modules
No jQuery or Prototype!
(okay, it has jQuery Light)
Web‑App
AngularJS
Frontend
<= REST API =>
Magento
Customers
Products
Orders
Payments
Downloads
Admin Interface
Planning
Reduce to the max!
Starting out
Magento CE 1.8.1.0
angular‑seed 
Magento REST API
Basics
REST API
!==
SOAP APIs
Mage_Api2
Resources

Products,
Product
Categories,
Product
Images,
Product
Websites

Stock Items

Customers,
Customer
Addresses

Orders,
Order Items,
Order
Addresses,
Order
Comments
Resource Attributes
You know the drill...
 Products have Names, ...
 Customers have Groups, ...
Resource Routes
/api/rest/products/category/10/store/2
Route Action Types
Collection
/api/rest/products/category/10/store/2
Entity
/api/rest/products/16
Operations
Mapping of HTTP verbs
GET => retrieve
POST => create
PUT => update
DELETE => delete
Roles
Admin
Customer
Guest
What weʹve got
Roles Resources
Attributes
Routes
Action Types
Operaton
Types
That all?
ACL
Each role can be allowed or denied potential access to each
resource by operation type via api2.xml.
E.g. guests may retrieve products, but not create them.
Under System > Web Services > REST ‑ Roles each potential role
permission has to be assigned, too.
Resource Attributes ACL
Same as roles... defined in XML, but ACL also has to be
assigned in the DB through the backend.
System > Web Services > REST ‑ Attributes
Not so elegant transition from theory to real stuff =>
Customize
the REST API
Customer Authentication
OAuth
Session Authentication!
REST API requests always run in admin store scope.
$_SERVER['MAGE_RUN_CODE'] is not evaluated.
Api2 Session Auth Adapter
1.  If frontend cookie exists
2.  Set current store to frontend
3.  Start frontend session
4.  Check if customer is logged in
Which store?
1.  Evaluate store cookie
2.  If not found, use the default
websites default store view
3.  Hope the customer belongs to
the website
Code
VinaiKopp_Api2SessionAuthAdapter 
VinaiKopp_Api2SessionLogin 
More REST Related
Extensions
VinaiKopp_Api2CreateAccount
VinaiKopp_Api2Directory
VinaiKopp_Api2SessionCustomerAddress
VinaiKopp_Api2ForgotPassword
VinaiKopp_Api2Downloads
Grokking_Api2Checkout
(coming to github as time allows ‑ pls ask if you need sooner)
The Frontend
7
things
I dig
ʹbout 
1. Modules
angular.module('magentoApp',[]);
angular.module('magentoApp',['ngRoute']);
Look Ma, Module Dependencies!
Modules provide things
angular.module('magentoApp',['ngRoute'])
.factory('Countries',function(){
return{
code:'ES',name:'Espania'
};
});
Things modules provide
Services
Controllers
Directives
Filters
and more...
2. Dependency Injection
If a module needs a thing...
...just add it to the
arguments
.controller('RegistrationCtrl',function($scope,Countries){
$scope.countries=Countries;
})
3. Mangling Protection
JavaScript Compression
I HAZ TEH MINIFICATSION! (meow)
Variable names made shorter...
KILLS the DI!
Mangling Protection
.controller('RegistrationCtrl',['Countries',function($scope,Countries){
$scope.countries=Countries;
}])
4. Promises
Asynchronous Things
XHR Requests and setTimeout Callbacks
Callback Try & Catch
Countries.fetch().
then(verifyAddress).
then(createAddress).
catch(displayAlert);
Can be combined!
$q.all(Countries.fetch(),Regions.fetch()).
then(verifyAddress).
then(createAddress).
catch(displayAlert);
5. REST Resources
Inject $resource...
.factory('ForgotPassword',['$resource',function($resource){
return$resource('/api/rest/customer/forgotpassword/:email');
});
...and use
varresult=ForgotPassword.get({
email:email
});
Custom actions!
.factory('ForgotPassword',['$resource',function($resource){
varresource=$resource('/api/rest/customer/forgotpassword/:email',{},{
validate:{method:'GET',isArray:true},
reset:{method:'PUT',isArray:false}
});
});
Fluid code :)
varresult=ForgotPassword.verify({
email:email,
token:token
});
6. Model Data Binding
[   ]
<p>{{example}}</p>
<inputtype="text"ng-bind="example">
Show Example
7. Testability
it('shouldcallcalcRowTotal()whenaddItemiscalledwithanewitem',
function(){
expect(cart.items.length).toBe(0);
cart.addItem(mock_product);
expect(mock_item.calcRowTotal).toHaveBeenCalled();
});
Would I do it again?
Yeaaah!
Complications
aka ʺOpportunities for Growthʺ
Scope Nesting
can be tricky
Frontend Architecture
Build a mini‑framework
Session State Management
Splash Messages
Consistent error handling
Bad Crunch‑Time
Descisions
Last Friday I was running out of time
so I decided to continue without TDD
A lesson learned...
again
I need more time to test manually then to write the tests.
Dankeschön!
@VinaiKopp on 
Api2 Extensions on GitHub 


Contenu connexe

En vedette (8)

Angular JS and Magento
Angular JS and MagentoAngular JS and Magento
Angular JS and Magento
 
Angular PWA
Angular PWAAngular PWA
Angular PWA
 
Magento Best Practices
Magento Best PracticesMagento Best Practices
Magento Best Practices
 
Magento 2: Modernizing an eCommerce Powerhouse
Magento 2: Modernizing an eCommerce PowerhouseMagento 2: Modernizing an eCommerce Powerhouse
Magento 2: Modernizing an eCommerce Powerhouse
 
Magento Business proposal
Magento Business proposalMagento Business proposal
Magento Business proposal
 
Ecommerce website proposal
Ecommerce website proposalEcommerce website proposal
Ecommerce website proposal
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Seo en Magento
Seo en MagentoSeo en Magento
Seo en Magento
 

Similaire à One page shops with Magento & Angular Js - Vinai Kopp

Sabarish_php_resume
Sabarish_php_resumeSabarish_php_resume
Sabarish_php_resume
sabarish K
 
Final project viva presentation
Final project   viva presentationFinal project   viva presentation
Final project viva presentation
teshan
 
Javascript library toolbox
Javascript library toolboxJavascript library toolbox
Javascript library toolbox
Skysoul Pty.Ltd.
 
12 trung-oss-magento-overview
12 trung-oss-magento-overview12 trung-oss-magento-overview
12 trung-oss-magento-overview
Nguyen Duc Phu
 
Magento overview and how sell Magento extensions
Magento overview and how sell Magento extensionsMagento overview and how sell Magento extensions
Magento overview and how sell Magento extensions
Võ Duy Tuấn
 

Similaire à One page shops with Magento & Angular Js - Vinai Kopp (20)

Lizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17deLizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17de
 
Introduction to SPA with AngularJS
Introduction to SPA with AngularJSIntroduction to SPA with AngularJS
Introduction to SPA with AngularJS
 
Иван Чепурный - Meet Magento Ukraine - Varnish Cache and its usage in the rea...
Иван Чепурный - Meet Magento Ukraine - Varnish Cache and its usage in the rea...Иван Чепурный - Meet Magento Ukraine - Varnish Cache and its usage in the rea...
Иван Чепурный - Meet Magento Ukraine - Varnish Cache and its usage in the rea...
 
Sabarish_php_resume
Sabarish_php_resumeSabarish_php_resume
Sabarish_php_resume
 
Getting Started with J2EE, A Roadmap
Getting Started with J2EE, A RoadmapGetting Started with J2EE, A Roadmap
Getting Started with J2EE, A Roadmap
 
OneNote to Rule Them All Slides.pptx
OneNote to Rule Them All Slides.pptxOneNote to Rule Them All Slides.pptx
OneNote to Rule Them All Slides.pptx
 
Final project viva presentation
Final project   viva presentationFinal project   viva presentation
Final project viva presentation
 
Vaadin DevDay 2017 - Web Components
Vaadin DevDay 2017 - Web ComponentsVaadin DevDay 2017 - Web Components
Vaadin DevDay 2017 - Web Components
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.js
 
Stego Product Overview
Stego Product OverviewStego Product Overview
Stego Product Overview
 
Introduction To Asp.Net Mvc
Introduction To Asp.Net MvcIntroduction To Asp.Net Mvc
Introduction To Asp.Net Mvc
 
Javascript library toolbox
Javascript library toolboxJavascript library toolbox
Javascript library toolbox
 
12 trung-oss-magento-overview
12 trung-oss-magento-overview12 trung-oss-magento-overview
12 trung-oss-magento-overview
 
Magento overview and how sell Magento extensions
Magento overview and how sell Magento extensionsMagento overview and how sell Magento extensions
Magento overview and how sell Magento extensions
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Shubham softsolution
Shubham softsolutionShubham softsolution
Shubham softsolution
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docs
 
(M) brochure full stack development learning path
(M) brochure full stack development learning path(M) brochure full stack development learning path
(M) brochure full stack development learning path
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
 

Plus de Meet Magento Spain

Mobile Commerce y Magento - Jaime Lopez
Mobile Commerce y Magento - Jaime LopezMobile Commerce y Magento - Jaime Lopez
Mobile Commerce y Magento - Jaime Lopez
Meet Magento Spain
 
SEO - Claves Estratégicas y Operativas - Néstor Tejero
SEO - Claves Estratégicas y Operativas - Néstor TejeroSEO - Claves Estratégicas y Operativas - Néstor Tejero
SEO - Claves Estratégicas y Operativas - Néstor Tejero
Meet Magento Spain
 
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirlResponsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Meet Magento Spain
 
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerceCómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Meet Magento Spain
 
UX: Responsabilidad Creativa en Ecommerce - Luz de León
UX: Responsabilidad Creativa en Ecommerce - Luz de LeónUX: Responsabilidad Creativa en Ecommerce - Luz de León
UX: Responsabilidad Creativa en Ecommerce - Luz de León
Meet Magento Spain
 
Social Commerce - Fernando Polo
Social Commerce - Fernando Polo Social Commerce - Fernando Polo
Social Commerce - Fernando Polo
Meet Magento Spain
 

Plus de Meet Magento Spain (12)

Mobile Commerce y Magento - Jaime Lopez
Mobile Commerce y Magento - Jaime LopezMobile Commerce y Magento - Jaime Lopez
Mobile Commerce y Magento - Jaime Lopez
 
SEO - Claves Estratégicas y Operativas - Néstor Tejero
SEO - Claves Estratégicas y Operativas - Néstor TejeroSEO - Claves Estratégicas y Operativas - Néstor Tejero
SEO - Claves Estratégicas y Operativas - Néstor Tejero
 
Fixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan ChepurnyiFixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan Chepurnyi
 
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirlResponsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
Responsive Vs Mobile Development in Magento - Kimberly Thomas - @MagentoGirl
 
Magento and Continuous Integration - Damian Luszczymak
Magento and Continuous Integration - Damian LuszczymakMagento and Continuous Integration - Damian Luszczymak
Magento and Continuous Integration - Damian Luszczymak
 
Hackathon MM14ES - Fabian Blechschmidt
Hackathon MM14ES - Fabian BlechschmidtHackathon MM14ES - Fabian Blechschmidt
Hackathon MM14ES - Fabian Blechschmidt
 
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerceCómo la Gamificación ayuda al Funnel de Venta en #eCommerce
Cómo la Gamificación ayuda al Funnel de Venta en #eCommerce
 
UX: Responsabilidad Creativa en Ecommerce - Luz de León
UX: Responsabilidad Creativa en Ecommerce - Luz de LeónUX: Responsabilidad Creativa en Ecommerce - Luz de León
UX: Responsabilidad Creativa en Ecommerce - Luz de León
 
SEO Magento - Irene Horna
SEO Magento - Irene HornaSEO Magento - Irene Horna
SEO Magento - Irene Horna
 
Social Commerce - Fernando Polo
Social Commerce - Fernando Polo Social Commerce - Fernando Polo
Social Commerce - Fernando Polo
 
La importancia del paquete 2.0 - Marc Brayo Seur
La importancia del paquete 2.0 - Marc Brayo SeurLa importancia del paquete 2.0 - Marc Brayo Seur
La importancia del paquete 2.0 - Marc Brayo Seur
 
Responsive Web Design - Tom Robertshaw
Responsive Web Design - Tom RobertshawResponsive Web Design - Tom Robertshaw
Responsive Web Design - Tom Robertshaw
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
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
 

Dernier (20)

Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

One page shops with Magento & Angular Js - Vinai Kopp