Skip to content

Instantly share code, notes, and snippets.

@zzpaul
zzpaul / Vendor\BonusPoint\Model\BonusPoint.php
Last active October 12, 2016 14:37
Magento 2 - Custom REST API
<?php
namespace Vendor\BonusPoint\Model;
use Vendor\BonusPoint\Api\BonusPointInterface;
class BonusPoint implements BonusPointInterface {
public function updateFreeBonusPoint($customerId, $point) {
// Do your logic here
@zzpaul
zzpaul / gist:f7f5801cfdc2e4e5569038cdabb27c4b
Created September 27, 2016 14:35
Magento 2 - Custom REST API - Vendor\BonusPoint\Api\BonusPointInterface.php
<?php
namespace Vendor\BonusPoint\Api;
interface BonusPointInterface {
/**
* Update free bonus point of a customer.
*
* @api
@zzpaul
zzpaul / gist:ef363fceb84227d3c0234590e6eacea1
Created September 27, 2016 14:33
Magento 2 - Custom REST API - etc/webapi.xml
<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/module-webapi/etc/webapi.xsd">
<route url="/V1/BonusPoint/updateFreeBonusPoint" method="POST">
<service class="Vendor\BonusPoint\Api\BonusPointInterface" method="updateFreeBonusPoint"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>
@zzpaul
zzpaul / gist:bebd89f4665a8ac81db5e3c4ac953ab7
Created September 26, 2016 15:22
Magento 2 - Add custom attribute in customer registration form
<?php
namespace vendor\TestModule\Setup;
use Magento\Customer\Model\Customer;
use Magento\Customer\Setup\CustomerSetup;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
<?php
$json = '{
"provider": "OMNIVA",
"type": "POST_OFFICE",
"name": "Abja-Paluoja postkontor",
"city": "Abja vald",
"country": "ESTONIA",
"availability": "E,T,K,R 8:30-13:00 ja 13:30-16:00;N 8:30-13:00 ja 13:30-18:00;L,P suletud",
"destination_id": 69400,
"street_address": "P\u00e4rnu maantee 8",
@zzpaul
zzpaul / gist:6203291
Created August 11, 2013 03:46
Bootstrap carousel
<div id="carousel-example-generic" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">