1

I'm creating custom rest API for getting a list of products. In my module, I have just use the getList function of ProductRepository. I need to pass select specific fields in API. so, how can I get that??

Note: In core API, we can get these response using below URL:

rest/V1/products?fields=items[name,qty,sku],total_count

I want to pass these fields programmatically.

2
  • you can use search Criteria using column name Nov 19, 2018 at 12:10
  • can you explain me , how can i achieve that??
    – Ratna Jain
    Nov 19, 2018 at 12:15

1 Answer 1

1

you have an API(rest/V1/products) -you can use search Criteria.

API(rest/V1/products)

you can use search Criteria using Column name

    http://<magento_host>/rest/V1/products/?
    searchCriteria[filter_groups][0][filters][0][field]=name&
    searchCriteria[filter_groups][0][filters][0][value]={VALUE}&
    searchCriteria[filter_groups][0][filters][0][condition_type]‌​=eq

method type : GET

The system creates an array, as shown in the following pseudo-code.

searchCriteria => [
  'filterGroups' => [
    0 => [
      'filters' => [
         0 => [
           'field' => 'name',
           'value' => 'YOUR VALUE',
           'condition_type' => 'eq'
         ]
      ]
    ]
  ]
2
  • I know this..but it's used for add where condition in result & i want to pass specific fields in select criteria.
    – Ratna Jain
    Nov 19, 2018 at 12:24
  • Please elaborate your concern. Nov 20, 2018 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.