Skip to content

Adobe Stock Image Search Design

Sergii Ivashchenko edited this page Jul 25, 2019 · 18 revisions

Overview

Search

Flow

SearchApi

Search Parameters

In order to provide more accurate search results should be the ability to modify the following search criteria:

Name Parameter Name Description Values
X per page limit Number of images per page 32 (default); 48; 64
Image type content_type Asset type to display all (default); photo; Illustration
Safe content offensive Include image with violence or nudity only safe (default); all
Isolated image only isolated Image subject is isolated from the background by being on a uniformly colored background. no (default); yes
Image orientation orientation images with specific orientation all (default); horizontal; vertical; square; panoramic
Image color colors Images that have specific color HEX
Price premium Standard or premium (more expensive) images include Premium (default); standard

Sorting

Parameter Description
relevance (default) How closely it matches your search request, closest matches first.
creation Creation date in descending order (newest first).
popularity In descending order by the number of views by all users.
nb_downloads In descending order by the number of downloads by all users since the asset was added to Adobe Stock.
undiscovered Starting with assets that have not commonly been viewed or downloaded.

Service Contracts

Search API service contracts details available on the Application Service Contracts page

Search Criteria processing

The \Magento\AdobeStockClientApi\Api\ClientInterface::search method is accepting \Magento\Framework\Api\SearchCriteriaInterface as an argument.

The client is using the collection of classes implementing \Magento\AdobeStockClientApi\Api\SearchParameterProviderInterface to process search criteria.

Processing new/custom parameters for a search request to Adobe Stock API

In case any additional parameters should be processed for Adobe Stock API search request the following actions should be performed:

  • Create a class implementing \Magento\AdobeStockClientApi\Api\SearchParameterProviderInterface
    • The required values should be transferred from SearchCriteria to SearchParameters by the implementation
  • Add the created class to \Magento\AdobeStockClient\Model\SearchParametersProviderComposite as an item in providers array constuctor parameter via di.xml arguments node

Example:

    <type name="Magento\AdobeStockClient\Model\SearchParametersProviderComposite">
        <arguments>
            <argument name="providers" xsi:type="array">
                <item name="orientation_filter" xsi:type="object">Magento\AdobeStockClient\Model\SearchParametersProvider\Orientation</item>
        ...
        </arguments>
    </type>

Simple filters

In case a value from a specific filter of SearchCriteria needs to be set to SearchParameters via specific methtod without any additional business logic, a new class is not necessary. A \Magento\AdobeStockClient\Model\SearchParametersProvider\SimpleFilters class can be configured via DI.

Example:

    <type name="Magento\AdobeStockClient\Model\SearchParametersProvider\SimpleFilters">
        <arguments>
            <argument name="filters" xsi:type="array">
                <item name="premium_price_filter" xsi:type="string">setFilterPremium</item>
                <item name="colors_filter" xsi:type="string">setFilterColors</item>
            </argument>
        </arguments>
    </type>
Clone this wiki locally