A Polymer e-commerce element for Magento 2

Overview

magento-collect

Master branch | Develop branch --- | --- | --- Build Status | Build Status

Note: this element is still in progress, watch it to follow the progress. This is like Agile and stuff

#UseThePlatform! The magento element is used to integrate Magento 2 through its RESTful APIs directly into a Polymer app or website.

The magento-collect element is an extension for Polymer and handles the collection of Magento 2 data through its REST API.

Installation

$ bower install --save bobvanluijt/magento-collect

Setup within Magento:

  • Enable the API: In case you setup Magento via the UI: webapi -> security -> allow insecure = true
  • Enable the API: in MySql: REPLACE INTO core_config_data (path, value) VALUES("webapi/webapisecurity/allow_insecure", 1);
  • Enable CORS on your webserver. Nginx CORS, Apache 2 CORS

You need to define these global settings:

<script>
Polymer({
	ready: function() {
		window.MageConfig = {
			RESTurl = 'https://someurl.com/rest/V1', // current domain by default
			immutableStore = true // true by default
		};
	}
});
</script>

Architectural principle

Magento 2 has a RESTful API.

The API follows the plural nouns RESTful approach. Example: /products/{id} for a single product and /products for a list of products.

The magento-collect element follows this pattern by using plural and singular nouns. Based on Swagger document: http://devdocs.magento.com/swagger/index_20.html

Element Resource
magento-collect-products catalogProductRepositoryV1 - GET /V1/products
magento-collect-product catalogProductRepositoryV1 - GET /V1/products/{id}
magento-collect-categories catalogCategoryManagementV1 - GET /V1/categories
magento-collect-category catalogCategoryRepositoryV1 - GET /V1/categories/{id}

The collector attribute defines which {id} should be collected.

The object returned is available through the <magento-item key="{objectKey}"> element.

A complete example:

<magento-collect-product collector="24-UB02">
	<h1><magento-item key="name"></magento-item></h1>
	<h3><magento-item key="created_at"></magento-item></h3>
</magento-collect-product>

Immutable Store

Immutable storage is inspired by Netflix's Falcor. If you collect data, you can store it locally during a session. When a user goes back to a previously visited page, it will first travel the local object to find the information needed rather than going to the API directly.

Usage and overview of available sub-elements

Overview:

<magento-collect-product>

<magento-collect-product collector=""></magento-collect-product>

The complete product becomes available with by binding it within the tags.

<magento-collect-product collector="24-MB01">
  <!-- More information -->
</magento-collect-product>

You can also combine data bindings with conditionals.

<magento-collect-product collector="24-MB01">
	<template is="dom-repeat" items="{{ MAGE.product.media_gallery_entries.item }}">
		<iron-image is="dom-if" src="{{ file }}"></iron-image>
	</template>
</magento-collect-product>

<magento-collect-products>

You can also collect products using filters, for example all products that start with a certain name. This might also be use to collect multiple products.

You can define multiple filters by using a semicolon as seperator.

<magento-collect-products></magento-collect-products>

The complete product becomes available with double curly braces. The filtering work as follows:

  • Add filter="" tag and add
<magento-collect-products filter="name['Leggings']&condition_type=['like'];name['Parachute']&condition_type=['like'];">
  <template is="dom-repeat" items="{{ collection }}">
    <iron-image is="dom-if" src="{{ name }}"></iron-image>
  </template>
</magento-collect-products>

The filters and criteria are based on the Magento 2 WebAPI Search Criteria.

The Mage-Polymer-Object

The Magento 2 Object is saved following the GET endpoint responses.

For example:

When an element has the following bindings: {{ MAGE.product.name}} and {{ MAGE.product.weigth}} it will result in the request: [RESTURL]/products/24-MB01?fields=name,weigth. It will locally create the following MAGE object:

{
	"MAGE": {
		"/products/24-MB01": {
			"name": "Joust Duffle Bag",
			"weight": 0
		}
	}
}

If a new call is done to the Magento 2 API it will first check the collected information in the MAGE object. If it is not available in the object it will collect it from the Magento API setting the filter for this specific values.

In the above example, requesting: {{ MAGE.product.name }} and {{ MAGE.product.type_id }} will result in the request: [RESTURL]/products/24-MB01?fields=type_id

This feature can be disabled (see (Installation)[#Installation] )

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

Bob van Luijt (@bobvanluijt)

License

See license.md file.

You might also like...
Food theme for Commerce, intended for food delivery/pickup use cases

Food theme for Commerce ################################ WORK IN PROGRESS - NOT READY FOR USE ################################ This theme for Commerce

Open Source Data & Experience Management Platform (PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce)
Open Source Data & Experience Management Platform (PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce)

Pimcore - Open Source Data & Experience Management Platform: PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce

This Magento 2 extension integrates EasyTranslate into Magento 2.
This Magento 2 extension integrates EasyTranslate into Magento 2.

EasyTranslate Magento 2 Connector This Magento 2 extension integrates EasyTranslate into Magento 2. Mind that you need to have an account with EasyTra

Magento-Functions - A Resource of Magento Functions

Magento-Functions A Resource of Magento Functions Table of Contents Category Product User Cart Checkout General Account [Working w/ URL's] (#urls) Cat

Magento - Magento Community Editions

Magento Community Edition /// THIS REPOSITORY IS DEPREACTED /// 1.9.4.1 will be the last version update. Please switch over to OpenMage! Either to the

Magento-Vagrant-Puppet-Nginx - Installs magento and a nginx server

Magento-Vagrant-Puppet-Nginx Installs Magento MySQL PHP PHP-FPM Nginx n98-magerun Setup git submodule init git submodule update vagrant up Modify pupp

Docker-magento - Docker image for Magento 1.6 to 1.9

Docker image for Magento 1.x This repo creates a Docker image for Magento 1.x. Please note The primary goal of this repo is to create Docker images fo

Magento-composer-installer - Composer installer for Magento modules
Magento-composer-installer - Composer installer for Magento modules

!!! support the maintainer of this project via Patreon: https://www.patreon.com/Flyingmana Magento Composer Installer The purpose of this project is t

Chef-magento - Installs and Configures a Magento project

Description Requirements Chef 0.10.0 or higher required (for Chef environment use). Platform Debian, Ubuntu CentOS, Red Hat, Fedora Your basebox must

Comments
  • Create render engine based on the Swagger API

    Create render engine based on the Swagger API

    Description

    The Magento 2 Swagger document should be used to create custom requests.

    There should be a config file that states something like this:

    [{
        "element": "radon-collect-product",
        "swaggerTag": "catalogProductRepositoryV1",
        "method": "get",
        "endpoint": "/V1/products/{sku}"
    }, {
        "element": "radon-collect-products",
        "swaggerTag": "catalogProductRepositoryV1",
        "method": "get",
         "endpoint": "/V1/products"
    }
    }, {
        // etcetera
    }]
    
    1. When the bower component is installed, all these elements should be generated. Or, they should be pre-generated in the Bower directory.
    2. The url params should be available as elements (like {sku} as sku="")
    3. Filters should be integrated in the filter element (see readme file)

    Swagger URL: http://devdocs.magento.com/swagger/schemas/latest-2.1.schema.json

    opened by bobvanluijt 0
  • Integrate the iron-ajax element to handle AJAX requests

    Integrate the iron-ajax element to handle AJAX requests

    Description

    Handle ajax request with ajax and the iron element

    Expected outcome

    A request should be done to the Magento 2 webapi to request and receive data.

    opened by bobvanluijt 0
Releases(v0.0.0)
Owner
Bob van Luijt
CEO & co-founder of @semi-technologies
Bob van Luijt
Migration Tool for Magento Commerce (EE) to Magento OpenSource (CE)

Migration Tool for Magento Commerce to Magento OpenSource Also known as Magento Enterprise (EE) to Magento Community (CE). This migrating tool allows

OpenGento 38 Dec 28, 2022
This library provides HTML5 element definitions for HTML Purifier, compliant with the WHATWG spec

HTML5 Definitions for HTML Purifier This library provides HTML5 element definitions for HTML Purifier, compliant with the WHATWG spec. It is the most

Mateusz Turcza 92 Nov 16, 2022
REDAXO-Addon mit nützlichen Methoden im Umgang mit dem Picture-Element, Responsive Bilder, SVG-Ausgabe, u.v.m.

REDAXO-Addon mit nützlichen Methoden im Umgang mit dem Picture-Element, Responsive Bilder, SVG-Ausgabe, u.v.m.

alex+ Informationsdesign 8 Dec 15, 2022
REDAXO-Addon mit nützlichen Methoden im Umgang mit dem Picture-Element, Responsive Bilder, SVG-Ausgabe, u.v.m.

REDAXO-Addon mit nützlichen Methoden im Umgang mit dem Picture-Element, Responsive Bilder, SVG-Ausgabe, u.v.m.

alex+ Informationsdesign 8 Dec 15, 2022
Provides a foundation for developing with Magento Commerce in a Vagrant box

Provides a foundation for developing with Magento Commerce in a Vagrant box. The machine is based on CentOS 6.4. ==== List of installed software. Mage

Jason Evans 19 May 12, 2017
Magento Firewall for securing your e-commerce system.

MageFirewall Magento Firewall for securing your e-commerce system. Tested to work with Magento 1.6 and above. ###Features Neat Dashboard. Alert / List

Paim pozhil 35 Sep 26, 2018
A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2

Simple Import / Export tool A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2. Table data

EcomDev B.V. 51 Dec 5, 2022
Bundle providing Honeypot field for the Form Builder in Ibexa DXP Experience/Commerce (3.X)

IbexaHoneypot Bundle providing Honeypot field for the Form Builder in Ibexa DXP Experience/Commerce (3.X) What is Honey pot? A honey pot trap involves

null 1 Oct 14, 2021