# Product search

{% hint style="danger" %}
Implementation is **REQUIRED**
{% endhint %}

### Implementation

You only need to create a new class, implement **`ProductSearchAdapter`** interface and fill all required methods.  API endpoints for product search are created automatically and secured with token.&#x20;

It is important to add `@Component` annotation on top of the class. There is no restriction for class name or location in your project. Our SDK will find your implementation based on the interface (DI).

```java
import ee.smarts.common.v1.Entities.product.Product;
import ee.smarts.common.v1.requests.ProductSearchRequest;
import ee.smarts.starter.adapter.ProductSearchAdapter;
import org.springframework.stereotype.Component;
import java.util.List;

@Component
public class ProductSearchImpl implements ProductSearchAdapter {
    @Override
    public Product searchByBarcode(ProductSearchRequest request) { 
        // implement this method
        return null;
    }
    @Override
    public List<Product> searchByName(ProductSearchRequest request) { 
        // implement this method
        return null;
    }
    @Override
    public Pageable<Product> findAll(PageRequest<ProductSearchRequest> productSearchRequest){
        // implement this method
        return null;
    }
    @Override
    public List<Category> findProductCategories(InstitutionRequest institutionRequest){
        // implement this method
        return null;
    }
}
```

### Methods description

#### searchByBarcode

Method used to request product details based on product SKU code. Used for: adding product to shopping cart, adding product to shopping list, purchase check validation.&#x20;

#### searchByName

Method used to request products which contains in the name requested string. Used for: adding product to shopping cart from catalog, adding product to pickup order from catalog.&#x20;

#### findAll

Method used to display products in product catalog.&#x20;

#### findProductCategories

Method used to display product categories in product catalog.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.smarts.ee/integration/spring-boot-starter/product-search.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
