All Projects → grayloon → magento-laravel-api

grayloon / magento-laravel-api

Licence: MIT License
A simple Magento 2 REST API Object Oriented wrapper for Laravel applications.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to magento-laravel-api

artisan-cloudflare
Laravel artisan commands for CloudFlare
Stars: ✭ 67 (+48.89%)
Mutual labels:  laravel-package
smart-schema
A Laravel package to enable auto generation of forms
Stars: ✭ 18 (-60%)
Mutual labels:  laravel-package
m2-ComposerRepo
Composer Repository Manager for selling Magento 2 extension and offering composer installation for ordered packages.
Stars: ✭ 18 (-60%)
Mutual labels:  magento2
magento2-link-product
Custom Product Relation for Magento 2.2.x and 2.3.x sample extension
Stars: ✭ 45 (+0%)
Mutual labels:  magento2
magento2-fast-vm
Optimal vagrant developer box for Magento2. Folders synced by nfs/rsync. This box includes Magento developer utilities.
Stars: ✭ 89 (+97.78%)
Mutual labels:  magento2
magento-2-ajax-cart
Magento 2 Ajax Cart allows customers to add products to cart right on the current window without having to redirect to another page. Completely reduce redirect wait times and improve the shopping experience.
Stars: ✭ 16 (-64.44%)
Mutual labels:  magento2
magerun2-addons
Addon modules for n98-magerun2
Stars: ✭ 19 (-57.78%)
Mutual labels:  magento2
laravel-sms-api
Laravel package to provide SMS API integration.
Stars: ✭ 84 (+86.67%)
Mutual labels:  laravel-package
dropzoner
Laravel package for image upload using DropzoneJS
Stars: ✭ 46 (+2.22%)
Mutual labels:  laravel-package
active-state
Laravel Active State Url Helper For Request
Stars: ✭ 45 (+0%)
Mutual labels:  laravel-package
laravel-miniprogram-poster
Use Laravel to building a miniprogram poster.
Stars: ✭ 72 (+60%)
Mutual labels:  laravel-package
devtube
Laravel YouTube and Online Video viewing and download interface.
Stars: ✭ 30 (-33.33%)
Mutual labels:  laravel-package
phpcsfixer-preset
Use the same php-cs-fixer configuration across all of your projects, with presets for common project layouts (Laravel, Composer packages, etc.).
Stars: ✭ 22 (-51.11%)
Mutual labels:  laravel-package
panichd
Ticketing system for Laravel 5.1 - 8.x. Allows to create new tickets via form only. Includes file attachments, ticket tags, filtering, scheduling and e-mail notifications.
Stars: ✭ 78 (+73.33%)
Mutual labels:  laravel-package
searchable
Pattern-matching search and reusable queries in laravel.
Stars: ✭ 28 (-37.78%)
Mutual labels:  laravel-package
Laravel-Unsplash-Wrapper
A Laravel wrapper for Unsplash API's.
Stars: ✭ 21 (-53.33%)
Mutual labels:  laravel-package
magento2-showoutofstockprice
This Magento2 Module adds prices and the add-to-cart button to out-of-stock configurable products.
Stars: ✭ 22 (-51.11%)
Mutual labels:  magento2
shield
A laravel middleware to protect against unverified webhooks from 3rd party services.
Stars: ✭ 96 (+113.33%)
Mutual labels:  laravel-package
magento2-module-pdf
Magento 2 Module for creating PDF's based on wkhtmltopdf
Stars: ✭ 55 (+22.22%)
Mutual labels:  magento2
laravel-bitcoinrpc
Bitcoin JSON-RPC Service Provider for Laravel.
Stars: ✭ 83 (+84.44%)
Mutual labels:  laravel-package

Build Status Latest Stable Version Style CI Total Downloads License

Laravel - Magento API

A Magento 2 API Object Oriented wrapper for a Laravel application.

Installation

Install this package via Composer:

composer require grayloon/laravel-magento-api

Publish the config options:

php artisan vendor:publish --provider="Grayloon\Magento\MagentoServiceProvider"

Configure your Magento 2 API endpoint and token in your .env file:

MAGENTO_BASE_URL="https://mydomain.com"
MAGENTO_ACCESS_TOKEN="client_access_token_here"

# Optional Config:
MAGENTO_BASE_PATH="rest"
MAGENTO_STORE_CODE="all"
MAGENTO_API_VERSION="V1"

API Usage

Example:

use Grayloon\Magento\Magento;

$magento = new Magento();
$response = $magento->api('products')->all();

$response->body() : string;
$response->json() : array|mixed;
$response->status() : int;
$response->ok() : bool;

Will throw an exception on >500 errors.

You may also utilize the constructor directly without having to configure environment variables:

use Grayloon\Magento\Magento;

$magento = new Magento(
    $baseUrl = 'https://my-magento-shop.com',
    $token = 'client_access_token',
    $version = 'V1',
    $basePath = 'rest',
    $storeCode = 'default'
);

$response = $magento->api('products')->all();

Available Methods:

Admin Token Integration (IntegrationAdminTokenServiceV1)

/V1/integration/admin/token

Generate a admin token:

Magento::api('integration')->adminToken($username, $password);

Bundle Product Options (bundleProductOptionRepositoryV1)

/V1/bundle-products/{sku}/options/all

Get all options for bundle product.

Magento::api('bundleProduct')->options($sku);

Carts

/V1/carts/mine

Returns information for the cart for the authenticated customer. Must use a single store code.

Magento::api('carts')->mine();

/V1/carts/mine/coupons/{couponCode}

Apply a coupon to a specified cart.

Magento::api('carts')->couponCode($couponCode);

Cart Items (quoteCartItemRepositoryV1)

/V1/carts/mine/items/

Lists items that are assigned to a specified customer cart. Must have a store code.

Magento::api('cartItems')->mine();

/V1/carts/mine/items/

Add/update the specified cart item with a customer token. Must have a store code.

Magento::api('cartItems')->addItem($cartId, $sku, $quantity);

put - /V1/carts/mine/items/{itemId}

Update the specified cart item with a customer token. Must have a store code.

Magento::api('cartItems')->editItem($itemId, $body = []);

Remove the specified cart item with a customer token. Must have a store code.

Magento::api('cartItems')->removeItem($itemId);

Cart Totals (quoteCartTotalRepositoryV1)

/V1/carts/mine/totals

Returns information for the cart totals for the authenticated customer. Must use a single store code.

Magento::api('cartTotals')->mine();

Categories (catalogCategoryManagementV1)

/V1/categories

Get a list of all categories:

Magento::api('categories')->all($pageSize = 50, $currentPage = 1, $filters = []);

Customer Token Integration (IntegrationCustomerTokenServiceV1)

/V1/integration/customer/token

Generate a customer token:

Magento::api('integration')->customerToken($username, $password);

Customers (various)

/V1/customers/search

Get a list of customers:

Magento::api('customers')->all($pageSize = 50, $currentPage = 1, $filters = []);

/V1/customers/password

Send an email to the customer with a password reset link.

Magento::api('customers')->password($email, $template, $websiteId);

/V1/customers/resetPassword

Reset customer password.

Magento::api('customers')->resetPassword($email, $resetToken, $newPassword);

Customer Groups

GET /V1/customerGroups/{id}

Show the customer group by the provided ID.

Magento::api('customerGroups')->show($id);

PUT /V1/customerGroups/{id}

Save the customer group by the provided ID.

Magento::api('customerGroups')->saveGroup($id, $customerGroupRepositoryV1SavePutBody = []);

DELETE /V1/customerGroups/{id}

Delete customer group by the provided ID.

Magento::api('customerGroups')->deleteGroup($id);

POST /V1/customerGroups

Save/Create Customer Group.

Magento::api('customerGroups')->createGroup($customerGroupRepositoryV1SavePostBody = []);

GET /V1/customerGroups/search

Search the Customer Groups.

Magento::api('customerGroups')->search($pageSize = 50, $currentPage = 1, $filters = []);

GET /V1/customerGroups/default

Get the default customer group.

Magento::api('customerGroups')->default();

PUT /V1/customerGroups/default/{id}

Set the default customer group.

Magento::api('customerGroups')->setDefault($id);

GET /V1/customerGroups/{id}/permissions

Determine if customer group can be deleted.

Magento::api('customerGroups')->permissions($id);

Guest Cart (various)

/V1/guest-carts

Enable customer or guest user to create an empty cart and quote for an anonymous customer.

Magento::api('guestCarts')->create();

/V1/guest-carts/{cartId}

Return information for a specified cart.

Magento::api('guestCarts')->cart($cartId);

/V1/guest-carts/{cartId}/items

List items that are assigned to a specified cart.

Magento::api('guestCarts')->items($cartId);

/V1/guest-carts/{cartId}/items

Add/update the specified cart item.

Magento::api('guestCarts')->addItem($cartId, $sku, $quantity);

put - /V1/guest-carts/{cartId}/items/{itemId}

Update the specified cart item.

Magento::api('guestCarts')->editItem($cartId, $itemId, $body = []);

Remove the specified cart item.

Magento::api('guestCarts')->removeItem($cartId, $itemId);

/V1/guest-carts/{cartId}/estimate-shipping-methods

Estimate shipping by address and return list of available shipping methods.

Magento::api('guestCarts')->estimateShippingMethods($cartId);

/V1/guest-carts/{cartId}/coupons/{couponCode}

Apply a coupon to a specified cart.

Magento::api('guestCarts')->couponCode($cartId, $couponCode);

/V1/guest-carts/{cartId}

Assign a specified customer to a specified shopping cart.

Magento::api('guestCarts')->assignCustomer($cartId, $customerId, $storeId);

Orders (salesOrderRepositoryV1)

Lists orders that match specified search criteria.

/V1/orders

Magento::api('orders')->all($pageSize = 50, $currentPage = 1, $filters = []);

/V1/orders/{id}

List a specified order:

Magento::api('orders')->show($orderId);

/V1/orders

Performs persist operations for a specified order.

Magento::api('orders')->edit($entity = []);

Product Attributes (catalogProductAttributeRepositoryV1)

/V1/products/attributes/{attributeCode}

Retrieve specific product attribute information:

Magento::api('productAttributes')->show($attributeCode);

Product Link Types (catalogProductLinkTypeListV1)

/V1/products/links/types

Retrieve information about available product link types:

Magento::api('productLinkType')->types();

Products (catalogProductRepositoryV1)

/V1/products

Get a list of products:

Magento::api('products')->all($pageSize = 50, $currentPage = 1, $filters = []);

/V1/products/{sku}

Get info about a product by the product SKU:

Magento::api('products')->show($sku);

Custom Modules

Magento modules can have their own API endpoints. For example:

<route method="POST" url="/V1/my-custom-endpoint/save">
    ...
</route>
<route method="GET" url="/V1/my-custom-endpoint/get/:id">
    ...
</route>

To use these you can directly use get/post methods:

Magento::api('my-custom-endpoint')->post('save', [...]);
Magento::api('my-custom-endpoint')->get('get/1');

Schema

Get a schema blueprint of the Magento 2 REST API:

Magento::api('schema')->show();

Source Items (inventoryApiSourceItemRepositoryV1)

/V1/inventory/source-items

Get a list of paginated sort items (typically used for quantity retrieval):

Magento::api('sourceItems')->all($pageSize = 50, $currentPage = 1, $filters = []);

Sources (inventoryApiSourcesRepositoryV1)

/V1/inventory/sources

Get a list of paginated sources.

Magento::api('sources')->all($pageSize = 50, $currentPage = 1, $filters = []);

/V1/inventory/sources/{$name}

Get a specified source.

Magento::api('sources')->bySourceName($name);

Stocks (inventoryApiStocksRepositoryV1)

/V1/inventory/stocks

Get a list of paginated stocks.

Magento::api('stocks')->all($pageSize = 50, $currentPage = 1, $filters = []);

Store (storeGroupRepositoryV1)

/V1/store/storeConfigs

Get a list of store configs.

Magento::api('store')->storeConfigs();

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

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].