Magento 2 – Multi Site product filter using REST API

The first question that arise on looking at the tile is: What is Multi Site to do with REST API?

The answer is simple, Magento provides multi-site support and mobile application needs the same support through REST API.

The following steps will allow a developer to develop a module which will provide product filters for multiple sites with the help of RETS API.

Step 1:

Create a custom module Company Name/ Module Name like: Demo/Simple – I am pretty sure you can make this.

Step 2:

Create file ProductListInterface.php in Demo/Simple/Api Folder

Step 3:

Place the below code in ProductListInterface.php

This will allow the different search criteria filter.

Step 4:

Then create di.xml in Demo/Simple/etc Folder

Step 5:

Place the below code in di.xml

This will create a dependency to model.

Step 6:

Then create webapi.xml in Demo/Simple/etc Folder

Step 7:

Place the below code in webapi.xml

This will create routing for method.

Step 8:

Then create file ProductList.php in Demo/Simple/Model Folder

Step 9:

Place below code in ProductList.php

Step 10:

Run this REST API thru URL
http://yourdomain.com/rest/V1/productList?searchCriteria[current_page]=1&searchCriteria[page_size]=10&websiteIds=1

All Done.

Here are list of filter parameters which can be used via this:

mm

Mohit Bhesaniya PHP Developer

I work as Magento Developer in Yudiz Solutions Pvt. Ltd. - a leading mobile apps, Codeigniter and Magento2 company. I write blogs to be a self motivated next generation leader with the ability to adapt to rapidly changing technologies and environments.

Comments are closed.

Top