All Projects → rocwang → storefront

rocwang / storefront

Licence: MIT license
An Angular 2 storefront app for Magento 2 (unmaintained)

Programming Languages

HTML
75241 projects
typescript
32286 projects
SCSS
7915 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to storefront

ionic2 firebase shopping cart
Shopping cart built using Ionic2 and Firebase
Stars: ✭ 21 (-40%)
Mutual labels:  angular2
magento2-react-checkout
Highly Customizable Checkout for Magento 2, Built with React.
Stars: ✭ 165 (+371.43%)
Mutual labels:  magento2
ng2-visualizejs
A simple demonstration that draws a Jaspersoft report/dashboard resource with Visualize.js library using the Angular Framework (aka Angular 2.0)
Stars: ✭ 16 (-54.29%)
Mutual labels:  angular2
ng-logger
Angular logger service
Stars: ✭ 65 (+85.71%)
Mutual labels:  angular2
module-notorama
Say no to Fotorama in Magento 2(.3) with Notorama.
Stars: ✭ 37 (+5.71%)
Mutual labels:  magento2
magento-2-gulp
Gulp for Magento 2. It works with core Magento styles (less) and structure. Uses default theme configs from dev/tools/grunt/configs/local-themes.js.
Stars: ✭ 37 (+5.71%)
Mutual labels:  magento2
mage-di-analyzer
🕵️‍♂️Calculates and reports how Magento modules affect Magento2 DI compilation process and boostrapping process
Stars: ✭ 18 (-48.57%)
Mutual labels:  magento2
leto
Leto: Realtime Application Stack [Angualr2, Rethinkdb/Horizon, ExpressJS] Web | Mobile | Desktop
Stars: ✭ 21 (-40%)
Mutual labels:  angular2
magento-2-reports
Magento 2 Reports extension Free from Mageplaza helps stores quickly access to advanced reports on Dashboard. As your shop grows, so is the amount of numbers you have to deal with everyday. Eventually, it would reach a point where you find yourself in dire need of a tool that can take care of the figures for you.
Stars: ✭ 39 (+11.43%)
Mutual labels:  magento2
magento2-gulpfile
Simple Gulpfile for Magento2
Stars: ✭ 16 (-54.29%)
Mutual labels:  magento2
magento2-installer-bash-script
Simplistic Magento 2 Installer Bash Script
Stars: ✭ 38 (+8.57%)
Mutual labels:  magento2
ng-treetable
A treetable module for angular 5
Stars: ✭ 32 (-8.57%)
Mutual labels:  angular2
magento2-db-log-cleaner
Magento2 Cron Log Cleaning
Stars: ✭ 23 (-34.29%)
Mutual labels:  magento2
django-angular2-fullstack-devops
All-in-one django/angular2 seed with cli interface for multi-environment devops on aws using ansible/packer/terraform
Stars: ✭ 54 (+54.29%)
Mutual labels:  angular2
module-dsu
No description or website provided.
Stars: ✭ 18 (-48.57%)
Mutual labels:  magento2
magento2
For any issues or questions please get in touch with us via [email protected]
Stars: ✭ 15 (-57.14%)
Mutual labels:  magento2
module-dsu-client
No description or website provided.
Stars: ✭ 17 (-51.43%)
Mutual labels:  magento2
Worldpay-Magento2-CG
Worldpay Magento 2 Plugin for Worldpay Corporate Gateway
Stars: ✭ 15 (-57.14%)
Mutual labels:  magento2
perspectiveapi-authorship-demo
Example code to illustrate how to build an authorship experience using the perspective API
Stars: ✭ 62 (+77.14%)
Mutual labels:  angular2
ng-data-picker
🏄🏼 A data picker based on Angular 4+ (like native datetime picker of iOS)
Stars: ✭ 24 (-31.43%)
Mutual labels:  angular2

An Angular 2 storefront app for Magento 2

Demo video

Magento 2 comes with rich REST API support, which contains almost every features you can find in the native front end. So in theory, we can build a standalone web app as an alternative storefront, which consumes the API provided by a headless Magento 2 instance.

As a proof of concept, I've been playing with Magento 2 and Angular 2 recently and built a Single Page App, in which you can browse the catalog, add products to cart and place a order. You can play with it at http://storefront.rocwang.me/. Note that it's still a prototype, and only tested under the newest Chrome, Firefox and Opera.

Magento 2 REST API

The REST API in Magento 2 gets much better support compared to Magento 1. Even better, it has Swagger schema support, which is like WSDL to SOAP. With this under our belt, we can automate the API document generation and client code generation. There is even a Javascript library which can consume the API and build the client stub on the fly, right in your browser!

To expose the API to a client, which might be running from a different domain to your Magento instance, we need to enable Cross Origin Resource Sharing in your Magento's web server.

Example configuration for Apache:

# Always set these headers.
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "86400"
Header always set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token"

# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]

Advantages

With the SPA architecture, we separate the static part and the dynamic part in Magento. This gives us a lot of benefits:

Flexibility

By getting rid of the complex page-based Magento layout and template system, it opens infinite possibilities for the front end design, with zero impact on the Magento side and the server. You can design the UI to be whatever we like, experiment with all of the cutting edge browser features you dreamed of, and deliver the best user experience you can think of. You can event rebuild the Magento admin UI as well.

Performance

Without composing and rendering the page on the server side, Magento is running as a service, while the representational layer is handled by user's browser. Only dynamic data is exchanged between the server and the browser via the API, this may reduce your server load dramatically and make your store much more responsive.

What's better is, you don't need to worry about page cache/hole punching any more (I'm talking to you, Varnish). You may still need performance optimization eventually, but now the concerns are separated. You just easily focus your optimization on the API side, or the front end side.

Scalability & Accessibility

The static/dynamic separation enable us to scale the application much more easily as well. For the front end part, we could just throw the prebuilt storefront to CDN and make your store faster. If built properly, the storefront could be accessible even offline. Imagine the user experience you deliver when the user could view your catalog even when internet is not available or you are taking Magento offline for a scheduled maintenance!

Challenges

Even tough the Magento is headless now, we still need a nicely built "head". Apart from the amount of work to rebuild every front end feature we like in Magento and add new fancy features. There are others Challenges specifically for SPA.

SEO & speed of initial load

We are building a e-commerce app here, search engine discoverability is crucial to our business! However, the app loads contents like category and products progressively with Javascript, which might be hard for Google and other search engines to find the catalog data. Further than that, this progressive/lazy loading behavior might be a good user experience during the running of app, but it may feels slow to the first time visitor. No one like the spinner, right?

To resolve these 2 issues, we could turn to a technique call Server Side Rendering, but that deserve another post.

Payment gateway integration

The integration among payment gateways, Magento and our app is definitely possible, but it needs careful implementation.

Some facts about the app

Languages Build time dependencies Run time dependencies
Angular 2 flavored HTML Gulp and its plugins Angular 2
SCSS -> CSS Browsersync jQuery
Typescript -> JS ... Semantic UI
System JS
...

Start the container

docker run --name storefront -e VIRTUAL_HOST=storefront.rocwang.me -d rocwang/storefront
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].