Quick and Advanced Search Container REST API Magento 2

Product search is a very critical part of any e-commerce website. When the customer needs a specific product, he searches in this quick and advanced search bar itself.

There are two REST APIs inside Magento, one for quick search and one for advanced search.

Under Quick Search, the customer enters a particular name or SKU, ie, enters the search term.

And then after that, it hits and as soon as there is a matching product with that particular name, we will get that product as a response.

If the customer wants the product to be visible in the middle of a particular range, then for that we have to use the advanced search container which is given below endpoint.

 

Magento 2 Quick and Advanced Search REST API

Two search containers are given below of Magento 2 Quick and Advanced Search REST API.

 

Quick Searches REST API in Magento 2

When we open the Magento 2 website, the normal product catalog search that appears is called the quick search container.

If we want to get the data of that quick search container through Rest API in Magento 2, then for that I am mentioning the endpoints below.

You can get the data by adding content-type application JSON and method entering the authorized bearer token in the header.

Endpoint:

https://wishusucess.com/rest/default/V1/search?searchCriteria[requestName]=quick_search_container&searchCriteria[filter_groups][0][filters][0][field]=search_term&searchCriteria[filter_groups][0][filters][0][value]=iphone

Method: GET

Header:

  • Authorization: Bearer <admin_token>
  • Content-Type: application/json

Example:Quick Search Container PRAM API

Response:

{
"items": [
{
"id": 14,
"custom_attributes": [
{
"attribute_code": "score",
"value": "116.2562599182128900"
}
]
},
{
"id": 8,
"custom_attributes": [
{
"attribute_code": "score",
"value": "116.2562599182128900"
}
]
},
{
"id": 4,
"custom_attributes": [
{
"attribute_code": "score",
"value": "116.2562599182128900"
}
]
},
{
"id": 1,
"custom_attributes": [
{
"attribute_code": "score",
"value": "116.2562599182128900"
}
]
},
{
"id": 2046,
"custom_attributes": [
{
"attribute_code": "score",
"value": "103.3388977050781200"
}
]
},
{
"id": 1722,
"custom_attributes": [
{
"attribute_code": "score",
"value": "103.3388977050781200"
}
]
},
{
"id": 688,
"custom_attributes": [
{
"attribute_code": "score",
"value": "38.7520866394043000"
}
]
},
{
"id": 23,
"custom_attributes": [
{
"attribute_code": "score",
"value": "6.4586811065673830"
}
]
},
{
"id": 15,
"custom_attributes": [
{
"attribute_code": "score",
"value": "6.4586811065673830"
}
]
},
{
"id": 3,
"custom_attributes": [
{
"attribute_code": "score",
"value": "6.4586811065673830"
}
]
}
],
"aggregations": {
"buckets": [
{
"name": "category_bucket",
"values": [
{
"value": "3",
"metrics": [
"3",
"7"
]
},
{
"value": "4",
"metrics": [
"4",
"5"
]
},
{
"value": "5",
"metrics": [
"5",
"2"
]
},
{
"value": "7",
"metrics": [
"7",
"2"
]
},
{
"value": "8",
"metrics": [
"8",
"2"
]
},
{
"value": "12",
"metrics": [
"12",
"1"
]
},
{
"value": "17",
"metrics": [
"17",
"1"
]
},
{
"value": "21",
"metrics": [
"21",
"1"
]
},
{
"value": "22",
"metrics": [
"22",
"1"
]
},
{
"value": "26",
"metrics": [
"26",
"1"
]
},
{
"value": "28",
"metrics": [
"28",
"1"
]
},
{
"value": "34",
"metrics": [
"34",
"2"
]
}
]
}
],
"bucket_names": [
"category_bucket"
]
},
"search_criteria": {
"request_name": "quick_search_container",
"filter_groups": [
{
"filters": [
{
"field": "search_term",
"value": "bag",
"condition_type": "eq"
}
]
}
]
},
"total_count": 10
}

 

 

Product Advanced Search Container REST API

By using this advanced search container REST API, you can do an advanced search of the product of the Magento store.

You can set the minimum price and set a maximum price.

Whatever product is in between the minimum price to the maximum price, you will see it as a response.

For example, if you have set the minimum price as 200 and the maximum price is 500, then all the products in the range between 200 to 500 will be shown to you as a response through this rest API

Endpoint

https://wishusucess.com/rest/default/V1/search?searchCriteria[requestName]=advanced_search_container&searchCriteria[filter_groups][0][filters][0][field]=price.from&searchCriteria[filter_groups][0][filters][0][value]=200&searchCriteria[filter_groups][0][filters][1][field]=price.to&searchCriteria[filter_groups][0][filters][1][value]=500

Method: GET

Header:

  • Authorization: Bearer <admin_token>
  • Content-Type: application/json

Body: Not required

Advanced Search Container REST API

 

Advanced Search Container PRAM in REST API

Advanced Search Container PRAM in API

 

Response:

{
"items": [],
"aggregations": {
"buckets": [],
"bucket_names": []
},
"search_criteria": {
"request_name": "advanced_search_container",
"filter_groups": [
{
"filters": [
{
"field": "price.from",
"value": "200",
"condition_type": "eq"
},
{
"field": "price.to",
"value": "500",
"condition_type": "eq"
}
]
}
]
},
"total_count": 0
}

 

Read more: Search REST API List: Magento 2 API List of Product Search Endpoint

How To Create Blogging Website at Cheap Price in 2022

Search REST API List: Magento 2 API List of Product Search Endpoint

Here I am giving you a complete list of all the search REST API list or product filtering REST APIs inside Magento 2.

This will give you easy access to the API collection in one place.

Search REST API in Magento 2

You can easily do this list of APIs together and when you create a mobile application, it will be very convenient to filter any kind of data.

Within this API list, you will find all the details of how to filter any product by category ID or search, how to remove the collection, in the list given below.

If you want information in detail, then by clicking on the related link given below, you can go to another page, where its complete detail with example is given.

 

Magento 2 List of All Search REST API

When you will go to another page by clicking on that link, there you have to use what methods, which token to use in authorization, what should be the body content type you will get.

1. Product Search REST API for Search And Filter

https://wishusucess.com/rest/V1/categories/115/products

2. Quick Searches REST API in Magento 2

https://wishusucess.com/rest/default/V1/search?searchCriteria[requestName]=quick_search_container&searchCriteria[filter_groups][0][filters][0][field]=search_term&searchCriteria[filter_groups][0][filters][0][value]=iphone

3. Advanced Search Container Magento 2 REST API

https://wishusucess.com/rest/default/V1/search?searchCriteria[requestName]=advanced_search_container&searchCriteria[filter_groups][0][filters][0][field]=price.from&searchCriteria[filter_groups][0][filters][0][value]=200&searchCriteria[filter_groups][0][filters][1][field]=price.to&searchCriteria[filter_groups][0][filters][1][value]=500

4. Gets Products Where The SKU Search in Magento 2 REST API

https://wishusucess.com/rest/default/V1/search?searchCriteria[requestName]=advanced_search_container&searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=Accessoires1278&searchCriteria[filter_groups][0][filters][0][condition_type]=like

5. Product Filter Using Price And SKU in Magento 2 REST API

https://wishusucess.com/rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=Coquefhoih72389&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][0][filters][1][field]=sku&searchCriteria[filter_groups][0][filters][1][value]=Coque12345&searchCriteria[filter_groups][0][filters][1][condition_type]=like&searchCriteria[filter_groups][1][filters][0][field]=price&searchCriteria[filter_groups][1][filters][0][value]=400&searchCriteria[filter_groups][1][filters][0][condition_type]=from&searchCriteria[filter_groups][2][filters][0][field]=price&searchCriteria[filter_groups][2][filters][0][value]=600&searchCriteria[filter_groups][2][filters][0][condition_type]=to

6. A Simple Search Using an in Conditions Type

https://wishusucess.com/rest/default/V1/products?searchCriteria[filter_groups][0][filters][0][field]=name&searchCriteria[filter_groups][0][filters][0][value]=Coque Carbone et Effet Brossé Silicone à Coins Renforcés&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][0][filters][1][field]=name&searchCriteria[filter_groups][0][filters][1][value]=Accessoires Apple iPhone&searchCriteria[filter_groups][0][filters][1][condition_type]=like

7. Logical and Condition Search REST API Magento 2

https://wishusucess.com/rest/default/V1/products?searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=Accessoires1278&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][1][filters][0][field]=price&searchCriteria[filter_groups][1][filters][0][value]=2500&searchCriteria[filter_groups][1][filters][0][condition_type]=lt

8. Magento 2 Logical AND and OR Search REST API

https://wishusucess.com/rest/default/V1/products?searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=Accessoires1278&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][0][filters][1][field]=sku&searchCriteria[filter_groups][0][filters][1][value]=Coquefhoih72389&searchCriteria[filter_groups][0][filters][1][condition_type]=like&searchCriteria[filter_groups][1][filters][0][field]=price&searchCriteria[filter_groups][1][filters][0][value]=200&searchCriteria[filter_groups][1][filters][0][condition_type]=from&searchCriteria[filter_groups][2][filters][0][field]=price&searchCriteria[filter_groups][2][filters][0][value]=600&searchCriteria[filter_groups][2][filters][0][condition_type]=to

 

If you need any kind of help in Magento 2 store development then you can mail or message us or call us immediately, we will try our best to help you in every way from development.

If any query is also related to mobile application development or creating a store using the Magento framework and facing any problem, you can take help from us.

 

Recommended Posts:

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Magento Store: Best 36 Magento Website Examples in The World

How to Call CMS Block Page in PHTML File in Magento 2

In this block, I am showing you how to call the cms block page inside Magento 2.

Whenever we customize the theme or create a new website, at that time we often need to show the content of the block page inside our p file.

Often we call CMS static block to display better data on the frontend.

Many times through CMS block we add slider image, banner image, or sometimes some special product, sales promotions, return policies, etc., and to call it in many places, we call that block in phtml file.

I am telling you step by step method how you can show data by calling the block page in a PHTML file.

Call CMS Block Page in PHTML

Before You Call Block Page in Magento 2 website you must have that block page.

To create a new block page, you can create a new blog by going inside the admin content.

Then you can decide its identifier yourself if you want and you can use that identifier wherever you want to call it.

 

Create Static Block Page in Magento 2

Login to Magento 2

Admin > Content > Block > Add New Block

Enable Block: When you enable the block, then the content is visible; if you disable it, the content is disabled

Block Title: The title of the block decides what purpose it is made for and what it should be known as.

Identifier: The identifier is basically to call that block. There can never be two blocks of a bean identifier. The identifier is always unique.

Store View: Select the store views to show the static block in.

Block Content: Whatever content you want to add inside the block like Image, Text, Title, Heading, Table, Product, etc. then these are all content when you call block anywhere then this content will appear

When you save the block, it appears as a content grid, then if you want to edit it in HTML format, then you can edit anything in it by clicking on the so as HTML.

Magento 2 CMS Block Page

 

Read more: Add Multiple Product Attribute Using InstallData in Magento2

 

How to Call CMS Block Page in PHTML File in Magento 2

Now below are the steps to call the CMS static block page in phtml file.

<?php
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('your_block_identifier')
->toHtml();
?>

or

<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('your_block_identifier_name')->toHtml();?>

 

Call Block Identifier in CMS Page

By using this below method you can display CMS static block content in any cms block page or any static block page.

{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}

 

How to Get CMS Static Block In XML

Code to display the CMS Static Block in the “Content.

If you want to call static block inside XML file then you can follow the below method for that.

In the XML file, you can mention either the identifier or the ID of the block and through that, you can call the block.

<referenceContainer name="content"> 
<block class="Magento\Cms\Block\Block" name="block_identifier"> 
<arguments> 
<argument name="block_id" xsi:type="string">block_identifier</argument> 
</arguments> 
</block> 
</referenceContainer>

You can call the CMS static block by adopting any of these methods.

Wherever you want to show data, whether it is a slider, whether it is a product, whether it is a promotion or any kind of block content, you can easily call it in any phtml file and show it on the frontend.

If you face any kind of problem in this then you can feel free to call us, talk or mail, we will be there 24*7 to assist you.

 

Similar Posts:

Add Custom Class on Checkout Form Field in Magento 2

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Get Category Page Detail Using Category Page REST API

While creating a mobile application we need to get the data of the list page through the Magento 2 category page rest API.

In this sequence, I am telling you the steps here, using which you can get the information of the category page through Magento 2 API.

If you are searching Magento 2 REST API to get all categories where the is_active attribute is true in that case also you can use the below api.

You can also get the data of the enabled category of any store through the default REST API of Magento 2 given below

This Magento API behaves in such a way that you can get only the data of the active category, then you can use this API.

If a category is disabled, its attribute will not be active

 

Category Collection REST API Magento 2

This Magento 2 REST api of the category page lets you get category collection through store view code.

Through this, you can get the collection of entire store category collection details.

Endpoint:

https://www.wishusucess.com/rest/default/V1/categories

Method: GET

Header

  • Content-type: application/json
  • Authorization: Bearer Admin Token

Authorization: Not required

Category Page REST API in Magento 2

 

Response:

{
"id": 2,
"parent_id": 1,
"name": "Default Category",
"is_active": true,
"position": 1,
"level": 1,
"product_count": 1181,
"children_data": [
{
"id": 38,
"parent_id": 2,
"name": "What's New",
"is_active": true,
"position": 1,
"level": 2,
"product_count": 0,
"children_data": []
},


{
"id": 29,
"parent_id": 2,
"name": "Promotions",
"is_active": false,
"position": 6,
"level": 2,
"product_count": 0,
"children_data": [
{
"id": 30,
"parent_id": 29,
"name": "Women Sale",
"is_active": true,
"position": 1,
"level": 3,
"product_count": 224,
"children_data": []
},
{
"id": 31,
"parent_id": 29,
"name": "Men Sale",
"is_active": true,
"position": 2,
"level": 3,
"product_count": 39,
"children_data": []
},
{
"id": 32,
"parent_id": 29,
"name": "Pants",
"is_active": true,
"position": 3,
"level": 3,
"product_count": 247,
"children_data": []
},
{
"id": 33,
"parent_id": 29,
"name": "Tees",
"is_active": true,
"position": 4,
"level": 3,
"product_count": 192,
"children_data": []
}
]
},
{
"id": 37,
"parent_id": 2,
"name": "Sale",
"is_active": true,
"position": 6,
"level": 2,
"product_count": 0,
"children_data": []
}
]
}

 

Read more: Get Product Image URL Via Magento 2 REST API

 

Get All Category Page Data Via API in Magento 2

There is not much difference between the first and this API, but through this API you can get the complete category data of any Magento  2 website.

Using this REST API of Magento, you can easily get any categories and their subcategories across the store

Endpoint:

https://www.wishusucess.com/index.php/rest/V1/categories/

Method: GET

Header

  • Content-type: application/json
  • Authorization: Bearer Admin Token

Authorization: Not required

Category Collection REST API

 

Response:

{
"id": 2,
"parent_id": 1,
"name": "Default Category",
"is_active": true,
"position": 1,
"level": 1,
"product_count": 1181,
"children_data": [
{
"id": 38,
"parent_id": 2,
"name": "What's New",
"is_active": true,
"position": 1,
"level": 2,
"product_count": 0,
"children_data": []
},
{
"id": 29,
"parent_id": 2,
"name": "Promotions",
"is_active": false,
"position": 6,
"level": 2,
"product_count": 0,
"children_data": [
{
"id": 30,
"parent_id": 29,
"name": "Women Sale",
"is_active": true,
"position": 1,
"level": 3,
"product_count": 224,
"children_data": []
},
{
"id": 31,
"parent_id": 29,
"name": "Men Sale",
"is_active": true,
"position": 2,
"level": 3,
"product_count": 39,
"children_data": []
},
{
"id": 32,
"parent_id": 29,
"name": "Pants",
"is_active": true,
"position": 3,
"level": 3,
"product_count": 247,
"children_data": []
},
{
"id": 33,
"parent_id": 29,
"name": "Tees",
"is_active": true,
"position": 4,
"level": 3,
"product_count": 192,
"children_data": []
}
]
},
{
"id": 37,
"parent_id": 2,
"name": "Sale",
"is_active": true,
"position": 6,
"level": 2,
"product_count": 0,
"children_data": []
}
]
}

 

 

REST API for All Category Details With Image File

In this API, you can also get the image URL of each category simultaneously.

Rest of the details will remain the same as before API.

Magento 2 API, with the help of which all the category data of any store along with the image of each category is also available

Endpoint:

https://wishusucess.com/index.php/rest/V1/categories/list?searchCriteria[filterGroups][0][filters][0][field]=parent_id&searchCriteria[filterGroups][0][filters][0][value]=2

Method: GET

Header

  • Content-type: application/json
  • Authorization: Bearer Admin Token

Authorization: Not required

All Category Details Using Image File

 

Response

{
"items": [
{
"id": 3,
"parent_id": 2,
"name": "Gear",
"is_active": true,
"position": 4,
"level": 2,
"children": "4,5,6",
"created_at": "2022-01-20 14:12:16",
"updated_at": "2022-01-20 14:12:17",
"path": "1/2/3",
"available_sort_by": [],
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "display_mode",
"value": "PAGE"
},
{
"attribute_code": "is_anchor",
"value": "0"
},
{
"attribute_code": "path",
"value": "1/2/3"
},
{
"attribute_code": "children_count",
"value": "3"
},
{
"attribute_code": "url_key",
"value": "gear"
},
{
"attribute_code": "url_path",
"value": "gear"
}
]
},
{
"id": 37,
"parent_id": 2,
"name": "Sale",
"is_active": true,
"position": 6,
"level": 2,
"children": "",
"created_at": "2022-01-20 14:15:55",
"updated_at": "2022-01-20 14:15:55",
"path": "1/2/37",
"available_sort_by": [],
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "display_mode",
"value": "PAGE"
},
{
"attribute_code": "is_anchor",
"value": "0"
},
{
"attribute_code": "path",
"value": "1/2/37"
},
{
"attribute_code": "children_count",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "sale"
},
{
"attribute_code": "url_path",
"value": "sale"
}
]
},
{
"id": 38,
"parent_id": 2,
"name": "What's New",
"is_active": true,
"position": 1,
"level": 2,
"children": "",
"created_at": "2022-01-20 14:15:55",
"updated_at": "2022-01-20 14:15:55",
"path": "1/2/38",
"available_sort_by": [],
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "display_mode",
"value": "PAGE"
},
{
"attribute_code": "is_anchor",
"value": "0"
},
{
"attribute_code": "path",
"value": "1/2/38"
},
{
"attribute_code": "children_count",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "what-is-new"
},
{
"attribute_code": "url_path",
"value": "what-is-new"
}
]
}
],
"search_criteria": {
"filter_groups": [
{
"filters": [
{
"field": "parent_id",
"value": "2",
"condition_type": "eq"
}
]
}
]
},
"total_count": 3
}

 

Similar Posts:

How to Get New Arrival Product REST API in Magento 2

Create Account REST API : How to Create an Account of Customer, Admin

 

Suggested Post:

BMLT Course in Hindi: Scope and Future Career in BMLT, Eligibility

Add Custom Class on Checkout Form Field in Magento 2

When we work on the checkout page of Magento 2 sometimes we need to add custom class on checkout form field.

The checkout page gets a bit complicated as it is made of Knockout js.

We can implement a plugin to add custom classes to any field in the customer shipping form on the checkout page in an easy way.

Through custom plugins, customers can add class to any field of the form.

Add Custom Class on Checkout Form Fields

In order to add a custom class on the checkout customer shipping form field, we will develop a custom plugin and through that will inject a class into any form field.

 

Step 1: Add Custom Class on Checkout Form Field Module Registration

For this first, we have to create a registration file so that we can register our custom plugin.

Wishusucess/CustomClass/registration.php
<?php 
/*
* Developer: Hemant Singh Magento 2 Professional
* Website: http://www.wishusucess.com/
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Wishusucess_CustomClass',
__DIR__
);

 

Read more: How to Earn Money Digitally By Blog Writing And Other Way

 

Step 2: Module File for Custom Class Plugin

In this step, we have to create a model file.

As we all know that this is a basic file that holds the basic information details of any model or plugin.

Wishusucess/CustomClass/etc/module.xml
<?xml version="1.0"?>
<!--
/**
* Developer: Hemant Kumar Singh Magento Developer
* Website: http://www.wishusucess.com/
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Wishusucess_CustomClass" setup_version="1.0.0" active="true"></module>
</config>

 

Step 3: Add Dependency Injection File for Custom Class

Here we will tell Magento through a dependency injection file that we are going to make changes to its core functionality through the plugin.

That's why both the file type and name of that plugin will be mentioned in this file.

Wishusucess/CustomClass/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/ObjectManager/etc/config.xsd"> 
<type name="\Magento\Checkout\Block\Checkout\AttributeMerger">
<plugin name="customAttributeMerger" type="\Wishusucess\CustomClass\Model\Plugin\AttributeMergerPlugin"/>
</type>
</config>

 

Step 4: Plugin to Add Custom Class in Form Field

Via this plugin class, we will do some merge in behavior in the checkout form field.

As the checkout form field is loaded, a class will be automatically added.

Through this class, you can decide in which field you have to add the class name.

Wishusucess/CustomClass/Model/Plugin/AttributeMergerPlugin

<?php
/**
* Developer: Hemant Kumar Singh Magento Developer
* Website: http://www.wishusucess.com/
*/
namespace Wishusucess\CustomClass\Model\Plugin;

class AttributeMergerPlugin
{
public function afterMerge(\Magento\Checkout\Block\Checkout\AttributeMerger $subject, $result)
{
if (array_key_exists('telephone', $result)) {
$result['telephone']['additionalClasses'] = 'teliphone_number';
}

return $result;
}
}

Here is an example, I have added a custom class in the Magento default telephone number form field named telephone_number.

You can make any changes you want by using this class.

Because of creating a plugin, you will not need to add anything to any other file.

 

Step 5: Run Below Command

Now you have to run the command given below, then clear the cache, now you will see the class name.

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy -f

php bin/magento c:c

Custom Class on Customer Field

Here you can see that the custom class telephone number has been added.

In this way, you can add a custom class to any of the customer form fields as per your wish.

The easiest way to add a class is through a plugin

 

Download This Plugin

 

Similar Posts:

Configure PayPal in Magento 2 : How to Integrate PayPal

PayPal Account: How to Create New PayPal Account, Transfer

How to Get New Arrival Product REST API in Magento 2

In this article, we will learn how to filter the products of a Magento 2 store using the REST API and we will also know how to get new arrival products REST API.

By the way, Magento 2 Provides a facility for the REST API that is well known as Swagger Module which contains all list of REST APIs resources:

Using this model, you can get the product by visualizing and testing it through REST API.

When you hit the URL of your store by typing swagger you will get the list details of all the APIs.

Like I have taken an example below, according to this example you enter your URL and hit it, then you will get the API.

Endpoint:

http://www.wishusucess.com/swagger

Here we are filtering the product on the basis of attribute and the name of that attribute is a new product.

So while filtering the product through Rest API, we will get the newly added product by filtering

 

 

Get New Arrival Products REST API

 

To filter a new product, what should be its search criteria and which method will be used, what access token will be used, the details of all these are given below.

Endpoint

https://www.wishusucess.com/rest/V1/products?searchCriteria[sortOrders][0][field]=created_at&searchCriteria[pageSize]=10

Method: GET

Header: 

  • Authorization: Bearer <admin token>
  • Content Type: application/json

Body: none

New Arrival Products REST API

Search Parameter for New Arrivals in REST API

 

Created At New Arrivals

Response:

{
"items": [
{
"id": 2007,
"sku": "WSH08-31-Purple",
"name": "Sybil Running Short-31-Purple",
"attribute_set_id": 10,
"price": 44,
"status": 1,
"visibility": 1,
"type_id": "simple",
"created_at": "2021-12-23 09:40:40",
"updated_at": "2021-12-23 09:40:40",
"weight": 1,
"extension_attributes": {
"website_ids": [
1
],
"category_links": [
{
"position": 0,
"category_id": "28"
},
{
"position": 0,
"category_id": "35"
},
{
"position": 0,
"category_id": "2"
}
]
},
"product_links": [],
"options": [],
"media_gallery_entries": [
{
"id": 3353,
"media_type": "image",
"label": "",
"position": 1,
"disabled": false,
"types": [
"image",
"small_image",
"thumbnail"
],
"file": "/w/s/wsh08-purple_main_1.jpg"
},
{
"id": 3354,
"media_type": "image",
"label": "",
"position": 2,
"disabled": false,
"types": [],
"file": "/w/s/wsh08-purple_back_1.jpg"
}
],
"tier_prices": [],
"custom_attributes": [
{
"attribute_code": "image",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "small_image",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "thumbnail",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "sybil-running-short-31-purple"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "category_ids",
"value": [
"28",
"35",
"2"
]
},
{
"attribute_code": "description",
"value": "<p>Fortunately, it's okay to look cute while you're working out. The Sybil Running Short combines a fun, color-blocked design with breathable mesh fabric for sporty-fun style.</p>\n<p>&bull; Blue running shorts with green waist.<br />&bull; Drawstring-adjustable waist.<br />&bull; 4\" inseam. Machine wash/line dry.</p>"
},
{
"attribute_code": "size",
"value": "174"
},
{
"attribute_code": "color",
"value": "57"
}
]
}
],
"search_criteria": {
"filter_groups": [],
"sort_orders": [
{
"field": "created_at",
"direction": null
}
],
"page_size": 1
},
"total_count": 2046
}

 

Similar Posts:

Create Account REST API : How to Create an Account of Customer, Admin

Magento 2 Login REST API: How to Login Customer, Admin

Wishusucess on GitHub

Create Account REST API : How to Create an Account of Customer, Admin

In this article, I am going to explain to you how to use create account rest api in Magento 2. In this, I will also explain to you how to create customer and admin accounts using REST API.

Whenever you order a product inside the Magento store, there are three ways to do it.

By creating a customer account, we can order the product, which we call registered users or they are also called logged-in customers.

Another way is that customers can order products without registering an account, whom we know as guest users.

The third way is that the guest customer is registered only at the time of ordering.

As a guest user who logs in or creates an account when ordering
Through this article, I am going to explain how to register a client through the REST endpoint.

 

 

Admin Create Account REST API

Now if you are looking for the REST API endpoint to create Magento 2 admin users s you can follow the below steps.

 

Endpoint:

The below details are the basic structure of REST APIs to call in Magento 2.

<HTTP verb> http://<host>/rest/<scope>/<endpoint>

HTTP headers:

Through this section, we send the required authentication details and tell the Magento store that we are the authentic user who can access the requested data.

Payload:

Through this section, we send necessary valid details along with the endpoint.

POST <host>/rest/<store_code>/V1/tfa/provider/google/authenticate
{
"username": "admin",
"password": "<admin-password>",
"otp": "<otp-value>"
}

There is no API to create a Magento admin user you can get the access token of the admin user by using the rest API.

But you can create an admin account from the Magento 2 store in the admin.

Admin Panel > System > Permissions > All User > New User.

 

Response:

When you use the Magento admin rest API to get the access token that returns the admin’s access token in the following format.

4r2jdjdr11j6gmau8990hcj6qk5unh3i

Now, whenever you need to access the backend details or any other details then you have to use this token in the header for the authorization in every call and that header token validate then allows you to access the store details.

 

 

Customer REST API to Create Account

 

To create a customer, we can send all the details in the payload, in the first step I have only added four fields to create a customer in a short way.

But when you create a customer through rest API, all the other fields are optional, that's why you don't need to add all the fields in order to create customer accounts. You can create a customer by sending only four details in the payload in the Rest API.

 

Method 1: REST API to Create Customer in Magento 2

Endpoint:

POST <host>/rest/<store_code>/V1/customers
http://www.wishusucess.com/rest/V1/customers

Method: POST

Authorization: Not required

Body: raw: JSON

Headers: Content-Type: application/json

{
"customer": {
"email": "cs.hemantsingh@gmail.com",
"firstname": "Hemant",
"lastname": "Singh"
},
"password": "aaAdm378in@#123"
}

Create Account REST API in Magento 2

 

Response:

{
"id": 4,
"group_id": 1,
"created_at": "2022-01-14 18:38:21",
"updated_at": "2022-01-14 18:38:21",
"created_in": "Default Store View",
"email": "cs.hemantsingh@gmail.com",
"firstname": "Hemant",
"lastname": "Singh",
"store_id": 1,
"website_id": 1,
"addresses": [],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
}
}

 

Method 2: Create Customer REST API

In this step I am adding full customer details in payload else other details will be the same as the first methiod.

create customer rest api in detail

Response:

{
"id": 5,
"group_id": 1,
"default_billing": "3",
"default_shipping": "3",
"created_at": "2022-01-14 19:02:46",
"updated_at": "2022-01-14 19:02:47",
"created_in": "Default Store View",
"email": "cs.hemants@gmail.com",
"firstname": "Hemant",
"lastname": "Singh",
"store_id": 1,
"website_id": 1,
"addresses": [
{
"id": 3,
"customer_id": 5,
"region": {
"region_code": "UP",
"region": "Uttar Pradesh",
"region_id": 566
},
"region_id": 566,
"country_id": "IN",
"street": [
"Noida"
],
"telephone": "7992293862",
"postcode": "201301",
"city": "Noida",
"firstname": "Hemant",
"lastname": "Singh",
"default_shipping": true,
"default_billing": true
}
],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
}
}

 

If you log in to your Magento 2 store with any of the username and password details that you have given while creating the account using REST API, then it will log in successfully.

Or if you go to All Customers in the admin of the store, then your new account that has been created will appear.

Now if you want to implement login functionality using Magento rest api then you can use login rest API.

 

Read more: Magento 2 Login REST API: How to Login Customer, Admin

 

Other Post:

PayPal Account: How to Create New PayPal Account, Transfer

Wishusucess on GitHub

Magento 2 Login REST API: How to Login Customer, Admin

I am going to explain the Magento 2 login REST API for mobile applications so by using those REST APIs you can develop the application using the Magento 2 e-commerce framework.

So these APIs are basically used for the login system for the customers and admin users. You can take help of these proper rest ways to implement the login functionality.

 

 

Magento 2 Login REST API

 

To access the data of any store of your magento, first of all, you have to define yourself that you are the genuine person accessing that data.

Authentication means you have to prove as a genuine user of customer it admin that allows Magento e-commerce store to identify the access rights. It means you have the right to access (administrator, integration, client, or guest) resources of the API call.

Now if you just want to check some things as a front-end customer then you have to log in customer and for that, you have to get a customer access token.

But if you want to access internal details of the store then for that you must have to authenticate your identity and get an access token of admin details.

 

 

Magento 2 Login Rest API Customer

 

Step 1: You must have a customer account in order to get access tokens of customers. If you don't have a user account then you can create a customer account first.

Step 2: Now you have to send the customer user details like username and password in the payload with the POST method.

Step 3: Get customer access token in response.

 

API URL: {baseurl}/rest/V1/integration/customer/token

Endpoint:

https://wishusucess.com/rest/V1/integration/customer/token

Method: POST

Authorization: Not required

Body:

{
   "username":"cs.hemantsingh@gmail.com",
   "password":"Admin@#44123"
}

Magento 2 Login REST API

Response:

l2l6ccj0hwvm6pvj7uy7oflr7k7uvabv

 

 

Admin Login REST API in Magento 2

 

If any mobile application is developed using Magento eCommerce then at that time we need to login to Magento admin through rest API.

Let us know what is the complete step of admin login via REST API, by following which we can get this access token.

Step 1: You need a Magento store admin account in order to get access tokens of your stores via rest API.

Step 2: Now by hitting the below details you can get the admin access token. Along with the rest API URL you have to send the admin username and password in the payload with the POST method.

Step 3: Get admin access token in response.

 

API URL: {baseurl}/rest/V1/integration/admin/token

Endpoint: 

https://wishusucess.com/rest/V1/integration/admin/token

Method: POST

Header: Not required

Body:

{
    "username":"admin32",
    "password":"Admin555@#123"
}

Magento 2 Login REST API

Response:

9nnv93lsivrfvzyzt1cgdw8f3xnij05v

 

Read more: Magento 2.4 Installation Guide: How to Install Magento 2.4.2

 

Similar Post:

How to Make Payment Using PayPal REST API in Magento 2

Configure PayPal in Magento 2 : How to Integrate PayPal

How to Make Payment Using PayPal REST API in Magento 2

I am going to explain to you how to make payments using the PayPal REST API call to create orders through PayPal in Magento 2 e-commerce platform.

Here I am using the PayPal payment method to create an order for which I will pay through PayPal REST API and complete the order.

So it is important to have the right API calls as well as the right payload to fulfill the order.

When we hit the Paypal API, other details like basic authorization and header details must also be correct, otherwise, the payment will not be completed.

 

Read more: Configure PayPal in Magento 2 : How to Integrate PayPal

 

Now the correct point is what is the correct API call and payload to complete the order using PayPal express payment method to process checkout payment get it done the order.

So let's start steps one by one in order to complete the product order via Paypal rest API.

 

 

Step 1: Get an Access Token PayPal Sandbox App

 

First of all, we have to do the configuration of Magento admin, for that you can follow this step of Paypal Integration in Magento 2.

When your account is created and all its details are received then you reach this step to get access token using Paypal rest API.

You can proceed to the next step only after getting the required sandbox account details from the PayPal Developer Dashboard, for this you can complete those steps of the development environment to get OAuth 2.0 client ID and secret credentials for the sandbox accounts.

The access token you received authorizes you to access the PayPal REST API server by using those tokens.

 

Endpoint:

https://api-m.sandbox.paypal.com/v1/oauth2/token

Method: POST

Authorization: Basic Auth

Username: My app and credentials(client_id)

Password: Client secret

Body: x-www-form-urlencoded

grant_type = client_credentials

Get PayPal Access Token For Apps

 

Step 2: Create Order Using PayPal REST API

 

Now by using the below payload details you can create an order and complete the payment by using Paypal REST Apis call.

Endpoint:

https://api-m.sandbox.paypal.com/v1/payments/payment

Method: POST

Header:

Content-type: application/json

Authorization: <access-token>

Authorization: Basic Auth

Username: my app and credentials(client_id)

Password: Client secret

{
"intent": "authorize",
"experience_profile_id": "XP-T8WE-L7SC-RN4L-QJAS",
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"currency": "USD",
"total": "1.25",
"details": {
"shipping": "0.1",
"subtotal": "1",
"tax": "0.15"
}
},
"payee": {
"email": "cs.hemantsingh@gmail.com"
},
"description": "Test paypal payment done on 13th Jan 2022",
"item_list": {
"items": [{
"name": "acessories belt monolog",
"quantity": "1",
"price": "1",
"sku": "test1",
"currency": "USD"
}],
"shipping_address": {
"recipient_name": "Hemant Singh",
"line1": "New test",
"city": "Saratoga",
"country_code": "US",
"postal_code": "95070",
"phone": "0116519999164",
"state": "CA"
}
}
}],
"redirect_urls": {
"return_url": "https://wishusucess.com/",
"cancel_url": "https://wishusucess.com/"
}
}

Create Order Using PayPal REST API

 

Response: Order Created Using PayPal Payment Method

{
"id": "PAYID-MHL4VTA69N500857X1559800",
"intent": "authorize",
"state": "created",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "1.25",
"currency": "USD",
"details": {
"subtotal": "1.00",
"tax": "0.15",
"shipping": "0.10"
}
},
"payee": {
"email": "cs.hemantsingh@gmail.com"
},
"description": "Test paypal payment done on 13th Jan 2022",
"item_list": {
"items": [
{
"name": "acessories belt monolog",
"sku": "acessoriebelt321",
"price": "1.00",
"currency": "USD",
"quantity": 1
}
],
"shipping_address": {
"recipient_name": "Hemant Singh",
"line1": "New test",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US",
"phone": "0116519999164"
}
},
"related_resources": []
}
],
"experience_profile_id": "XP-T8WE-L7SC-RN4L-QJAS",
"create_time": "2022-01-07T05:08:28Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MHL4VTA69N500857X1559800",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-47V04030JC5984021",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MHL4VTA69N500857X1559800/execute",
"rel": "execute",
"method": "POST"
}
]
}

 

 

Approval PayPal REST API Payments

 

Paypal Login Details: Enter your Paypal username

Password: Enter your Paypal password details

 

"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-50C051037E557641M",
"rel": "approval_url",

"method": "REDIRECT"

 

Now you have to hit the approval URL in your response body and proceed as a guest for the testing purpose and it will redirect to the website to review the order.

PayPal REST API for Payment

As soon as you do this complete step, then your order will be completed and it will automatically go to your website.

Configure PayPal in Magento 2 : How to Integrate PayPal

I will tell you to step by step method to How to integrate the PayPal payment gateway on Magento 2 checkout page or configure PayPal in Magento 2.

PayPal comes by default with Magento, but we have to integrate it, then the PayPal payment option comes on the checkout page.

The Magento Ecommerce Framework provides a default model for integrating the PayPal Express checkout account. This feature was not there in the old version of Magento, but in the above version of 2.1.8, this facility has been given.

 

 

PayPal Payment Gateway in Magento 2

 

Paypal Express Checkout is also easy to integrate and it is easy for the customer to make the payment.

Due to this, the credibility of the website also increases. And when the website looks reliable in the eyes of the customer, then its sales also increase.

PayPal Payment Gateway is the most used payment gateway in the world which is also known for being the fastest and most secure.

It accepts payments in almost all currencies and mediums like debit cards, credit cards, etc.

The above-mentioned reason is sufficient that it is used in any online store or to accept online payment,

Then let us know how to add the PayPal Express Checkout payment method on your Magento website.

 

 

Steps to Configure PayPal in Magento 2

 

In order to configure PayPal Payment Gateway in Magento 2, we have to follow the following steps.

  • Expand the Paypal Express Checkout section in Magento 2, Admin.
  • Create a PayPal Account
  • Go to developer Paypal my account section and then get PayPal, API Username, API Password, and API Signature.
  • Fill in all the required details in Magento 2 admin.
  • Admin > Store > Configuration > Sales > Payment Method > Select Merchant Location > PayPal Express
  • Just select test mode for testing purposes or not for live site

Configure PayPal in Magento 2

 

Step 1: Create PayPal Account

 

You have to first log in from the developer account section of PayPal and then click on API & SDK.

Log into paypal account

 

Now you have to go inside of My Apps and credentials PayPal developer account then click on generate sandbox access token button then your business sandbox details will be generated.

Configure PayPal in Magento 2

 

Now you have to click on the Paypal personal or business mail manage the account you will see view/see the details.

Get PayPal Account APIs Key Details

 

After clicking on the above button you will get the API Credentials details of PayPal for the PayPal Integration.

Get My Apps Credentials PayPal

 

 

Step 2: Configure PayPal in Magento 2 Admin

 

Now just go inside of admin section and fill in all the details.

Admin > Store > Configuration > Sales > Payment Method > Select Merchant Location > PayPal Express

Now your Magento 2 Paypal payment method configuration has been done.

After successful completion, when you go to the frontend of your Magento 2 store you will see the PayPal payment option.

 

 

How Frontend Looks After PayPal Integration

 

I am giving you some details below, by which you will be confirmed that your PayPal payment method has been completed.

First of all, you have to go to the product details page of Magento 2 you will see the PayPal payment option.

Then you will go to the mini cart and there you will also see the PayPal payment method.

Now you will go to the checkout page of Magento 2 and there you will also see the PayPal payment method option

All these proofs prove that your PayPal payment integration has been successfully completed.

 

 

Add PayPal on Product Details Page

 

When PayPal is successfully added, then this automatic option will appear on the product detail page.

If you want to keep this payment option on the product detail page, then you can keep it, otherwise, you can also remove it.

Configure PayPal in Magento 2 Product Detail Page

 

 

 

PayPal Payment Option in MiniCart

 

This feature comes by default in Magento, when your PayPal account is properly integrated, then this payment option starts appearing.

Configure PayPal in Magento 2 on Minicart

 

 

Configure PayPal in Magento 2 on Checkout Page

 

Now in the last step, your PayPal payment option appears as a payment method on Magento 2 checkout page.

Here any customer can make his payment using the PayPal payment gateway option.

PayPal accepts all payment methods.

Add PayPal Payment Method on Checkout Page

 

 

Conclusion

 

Although there are other default payment methods on the Magento website, the PayPal payment method is the most important of them and also more popular.

Because it provides the facility of making payments with the fastest, most secure, and best user experience.

This contributes even more to connecting the customers of website owners,

Due to all these great experiences, your website plays an important role in increasing the sales rates and attracting more customers.

 

Payment Gateway Integration Helpline

 

If you face any problem in integrating any payment gateway, then feel free to call us or message us.

We will solve any kind of problem immediately.

Helpline number:

Skype: cs.hemantsingh@gmail.com

Phone: +91-8197565002

 

Similar Posts:

Best Payment Gateway For Magento 2: List of Top 7 And How To Integrate