简体   繁体   中英

Get specific product with id via Rest API Magento 2

I want to get the information from an specific product.

I am using this reference in this moment, and get all the products in given searchCriteria:

http://www.mysite.co/rest/V1/products-render-info?storeId=1&currencyCode=cop

Is there a way I can send the product id in the url and get only all its information?

You can add the filter

http://www.mysite.co/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=entity_id&searchCriteria[filterGroups][0][filters][0][value]=1&searchCriteria[filterGroups][0][filters][0][condition_type]=eq

use field entity_id instead of id , value is product id here 1 , condition_type is equal to here eq .

You can fetch product info by SKU, not ID.

API endpoint (get method) will pull product info. vendor/magento/module-catalog/etc/webapi.xml

/V1/products/:sku

So, your rest API calling URL should be like this

http://www.mysite.co/rest/V1/products/productsku

Note: If you want to fetch product info by id, you probably need to create a simple rest API. you can check this out. https://magento.stackexchange.com/questions/282480/i-am-new-here-i-want-to-know-how-can-i-create-my-own-simple-api/282730

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM