Catalog

Contracts

CatalogContentRepositoryContract

The CatalogContentRepositoryContract is the interface for the catalogue content repository. This interface allows to read and update a catalogue's content. The content contains the specific catalogue data that is used in the exports.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public get(string $id):array

Returns the content of the catalogue.

Parameters
string $id The id of the catalogue
public update(string $id, array $data):array

Updates the content of the catalogue.

Parameters
string $id The id of the catalogue
array $data The content that should be inserted into the catalogue

CatalogExportFilterServiceContract

To be written

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public applyFilters(DocumentSearch
 $documentSearch, array $config):void
Parameters
DocumentSearch $documentSearch
array $config

CatalogExportRepositoryContract

The CatalogExportRepositoryContract is the interface for the catalogue export repository. It allows to receive an instance of CatalogExportServiceContract to export a specific catalogue.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public exportById(string $id):CatalogExportServiceContract

Returns an instance of CatalogExportServiceContract to export a specific catalogue.

Parameters
string $id The id of the catalogue
public initiateQueue(string $id):void

Initiates the queue which exports a specific catalogue.

Parameters
string $id
public download(string $id, string $hash = "", string $extension = "csv"):array

Provides the response with file attachment to download in browser

Parameters
string $id
string $hash
string $extension

CatalogExportServiceContract

The CatalogExportServiceContract is the interface for the catalogue export service. It allows you to configure and start the export of a catalogue.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public setAdditionalFields(array $additionalFields):void

Deprecated!

Use fields with the attribute 'hidden' and 'default' in Plenty\Modules\Catalog\Contracts\DataProviderContract::getData instead

Specifies fields that should be exported in addition to the mappings configured in the catalogue.

Parameters
array $additionalFields The fields that should be exported additionally. Each field will be specified by an entry in the array, while the key of that entry determines the key that the field will have in the exported item.
public addMutator(callable $mutator):void

Deprecated!

Use Plenty\Modules\Catalog\Contracts\TemplateContract::getPreMutators or Plenty\Modules\Catalog\Contracts\TemplateContract::getPostMutators instead.
Parameters
callable $mutator
public setSettings(array $settings):void

Defines the settings that are used in the mappings and for filtering.

Parameters
array $settings
public setNumberOfDocumentsPerShard(int $numberOfDocumentsPerShard):void

Deprecated!

Use Plenty\Modules\Catalog\Contracts\CatalogExportServiceContract::setItemsPerPage instead.
Parameters
int $numberOfDocumentsPerShard
public setItemsPerPage(int $itemsPerPage):void

Defines the amount of items that will be returned in each iteration of the export. In specific formats such as variation, it can have more results e.g. if items per page is set to 500, but variations 500 and 501 belong to the same item. In this case, variation 501 will also be returned.

Parameters
int $itemsPerPage The amount of items per page
public setUpdatedSince(Carbon
 $timestamp):void

Limits the results of items to only those that were updated after the given timestamp.

Parameters
Carbon $timestamp
public getResult():CatalogExportResult

Returns an instance of CatalogExportResult, which can be iterated to receive the different pages of the exported data.

public getPreview():void

CatalogRepositoryContract

The CatalogRepositoryContract is the interface for the catalogue repository. It allows you to create, read, update and delete catalogues.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public create(array $data):Catalog

Create a catalog

Parameters
array $data
public update(string $id, array $data):Catalog

Update a catalog

Parameters
string $id
array $data
public get(string $id):Catalog

Get the latest version of a catalog

Parameters
string $id
public getByVersion(string $id, string $version = ""):Catalog

Get a specific version of a catalog

Parameters
string $id
string $version
public restoreVersion(string $id, string $version = ""):Catalog

Restore a past version of a catalog to become latest

Parameters
string $id
string $version
public listVersions(string $id):Collection

Lists catalog versions

Parameters
string $id Catalog ID
public getArchive():array

Gets the archive

public restoreArchived(string $id):Catalog

Restores an archived catalog

Parameters
string $id
public delete(string $id):bool

Delete a catalog

Parameters
string $id Catalog ID
public copy(array $data):array

Copy a catalog or multiple catalogs

Parameters
array $data
public copyCatalog(string $id, array $modifiedAttributes):Catalog

Copy a single catalog

Parameters
string $id Catalog ID
array $modifiedAttributes Attributes to add or modify
public copyCatalogFormat(string $catalogId, array $data):array

Copy a catalog format

Parameters
string $catalogId Catalog ID
array $data
public all(int $page = 1, int $perPage = 25):PaginatedResult

Get list of all catalogs

Parameters
int $page
int $perPage
public activate(string $id, bool $active):array

Activate a catalog

Parameters
string $id
bool $active
public migrate():bool

Migrates catalogs from Dynamo DB to S3

public setFilters(array $filters = []):void

Sets the filter array.

Parameters
array $filters
public getFilters():void

Returns the filter array.

public getConditions():void

Returns a collection of parsed filters as Condition object

public clearFilters():void

Clears the filter array.

CatalogResultConverterContract

To be written

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public addData($data):void

Through this a single entry of a catalog result should be added

Parameters
$data
public getConvertedResult():string

Converts the data that was inserted into the specific output format

public getType():string

Returns the type of the converted result

public clear():void

Removes all the data that was previously added to this instance

CatalogRuntimeConfigContract

To be written

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public applyRuntimeConfig(TemplateContract
 $template, Catalog
 $catalog):void

Will be run before every export and is meant to provide filters on the template which can't be defined before the runtime of the export

Parameters
TemplateContract $template
Catalog $catalog
public applyPreviewRuntimeConfig(TemplateContract
 $template, Catalog
 $catalog):void

Will be run before every preview and is meant to provide filters on the template which can't be defined before the runtime of the preview

Parameters
TemplateContract $template
Catalog $catalog

CatalogRuntimeConfigProviderContract

To be written

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public isPreviewable():bool

Determines if a preview can be exported through catalogs that use the specific template

public getRuntimeConfigClass():string

Returns a class name through which the export can be configured with information that isn't known before the export runtime

public getResultConverterClass():string

Returns a class name through which the export result can be converted into the necessary format (e.g. json or csv)

CatalogTemplateProviderContract

The CatalogTemplateProviderContract is the interface that has to be implemented by the catalogue template providers. Each registered template should have a catalogue template provider (multiple templates can use the same one) to avoid booting them if they are not necessary. A catalogue template provider fills a template with data at the moment the template gets booted. Whenever it is possible, use the abstract class Plenty\Modules\Catalog\Templates\BaseTemplateProvider.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public getMappings():array

Returns the different mapping sections including the information which data provider fills them. Each entry in the array represents a section of the catalogue UI.

public getFilter():array

Returns the filters that will be applied in each export of templates that will be booted by this provider.

public getPreMutators():array

Returns the callback functions that will be applied to the raw data (so before the mapping occurs) of each item in the export. Every callback function will receive an array of the raw item data and should return this array with the changes that should be applied (e.g. function (array $item){ --your code-- return $item}).

public getPostMutators():array

Returns the callback functions that will be applied to the mapped data of each item in the export. Every callback function will receive an array of the mapped item data und should return this array with the changes that should be applied (e.g. function (array $item){ --your code-- return $item}).

public getSkuCallback():callable

Returns a callback function that is called if a field with the specific key "sku" got mapped. The function will receive the value that got mapped, the raw data array of this item and the type of the mapped source. It should return the new value (e.g. function ($value, array $item, $mappingType){ --your code-- return $value})).

public getSettings():array

Returns an array of settings that will be displayed in the UI of each catalogue with a template that uses this provider. The selected values for all those settings can then be used in the export.

public getMetaInfo():array

Returns an array of meta information which can be used to forward information to the export which could otherwise not be received.

DataProviderContract

The DataProviderContract is the interface for data providers. Data providers provide the available fields that can be mapped in a template to create a catalogue. Whenever it is possible, use one of the concrete implementations Plenty\Modules\Catalog\DataProviders\BaseDataProvider, Plenty\Modules\Catalog\DataProviders\KeyDataProvider or Plenty\Modules\Catalog\DataProviders\NestedKeyDataProvider.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public getData(string $query = ""):array

Returns the data that should be provided.

Parameters
string $query
public setTemplate(TemplateContract
 $template):void
Parameters
TemplateContract $template
public setMapping(array $mapping):void
Parameters
array $mapping

FieldGroupRepositoryContract

The FieldGroupRepositoryContract is the contract for the field group repository. It allows to retrieve fields of a field group. Field groups represent the different groups of available sources that can be seen in the data picker component in the catalogue UI. Each field represents a mappable source.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public getFields(string $id, int $page, int $itemsPerPage, string $parentId = null):PaginatedResult

Get list of fields

Parameters
string $id
int $page
int $itemsPerPage
string $parentId
public getFieldById(string $id, string $fieldId):array

Get field by id

Parameters
string $id
string $fieldId
public getFieldsByCatalogId(string $id, string $catalogId):array

Get Fields by id of the catalog

Parameters
string $id
string $catalogId
public fieldValuesTree(string $id, int $page, int $itemsPerPage):array
Parameters
string $id
int $page
int $itemsPerPage

NestedDataProviderContract

The NestedDataProviderContract is the interface for nested data providers. Nested data providers are used to provide nested options that can be selected for export. E.g. a list of categories of a specific marketplace. Whenever it is possible, use the concrete implementation Plenty\Modules\Catalog\DataProviders\NestedKeyDataProvider.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public getNestedData(string $parentId, string $query = "", array $meta = []):array

Returns the data of a specific level, which is determined via the id of a parent value.

Parameters
string $parentId
string $query
array $meta
public getDataByValue(string $id):array

Returns a specific value of the nested data determined by its id.

Parameters
string $id
public getData(string $query = ""):array

Returns the data that should be provided.

Parameters
string $query
public setTemplate(TemplateContract
 $template):void
Parameters
TemplateContract $template
public setMapping(array $mapping):void
Parameters
array $mapping

TemplateContainerContract

The TemplateContainerContract is the interface of the template container. The template container is a singleton, which allows to register and retrieve templates.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public register(string $name, string $type, string $providerClass = "", string $exportType = "Plenty\Modules\Catalog\Dummy\VariationCatalogExportType"):TemplateContract

Registers a new template that can be used to create a catalogue.

Parameters
string $name The specific name of the template
string $type The type of the template. Multiple templates can be grouped in one type
string $providerClass Class name of the provider that boots the template
string $exportType Determines which data is available for mappings in the export. The default is variation data. (Currently only variation data can be exported via catalogues.)
public getTemplates():array

Returns all registered templates.

public getTemplate(string $identifier):TemplateContract

Returns a specific template by its identifier.

Parameters
string $identifier

TemplateContract

The TemplateContract is the interface for templates. Templates are used to define a specific schema that can be used to create and configure a catalogue.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public getName():string

Returns the name of the template.

public getType():string

Returns the type of the template.

public getExportType():string

Returns the export type of the template.

public getMappings():array

Returns the mappings of a template.

public addMapping(array $mapping):void

Adds a mapping to the template. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
array $mapping
public addMutator(callable $callback):void

Deprecated!

Use Plenty\Modules\Catalog\Contracts\TemplateContract::addPreMutator or Plenty\Modules\Catalog\Contracts\TemplateContract::addPreMutator instead.
Parameters
callable $callback
public addPreMutator(callable $callback):void

Adds a pre mutator to the template. Pre mutators are applied to the export data before the mapping occurs. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
callable $callback
public addPostMutator(callable $callback):void

Adds a post mutator to the template. Post mutators are applied to the export data once the mapping occurred. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
callable $callback
public getFilter():array

Returns the filters of the template.

public addFilter(array $filter):void

Adds a filter to the template. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
array $filter
public getIdentifier():string

Returns the unique identifier of the template.

public getMutators():array

Deprecated!

Use Plenty\Modules\Catalog\Contracts\TemplateContract::getPreMutators or Plenty\Modules\Catalog\Contracts\TemplateContract::getPostMutators instead.
public getPreMutators():array

Returns the pre mutators of the template.

public getPostMutators():array

Returns the post mutators of the template.

public setSkuCallback(callable $callback):void

Defines the callback function that will be called after the mapping is done for a field with the key "sku".

Parameters
callable $callback
public getSkuCallback():callable

Retrieves the callback function that will be called after the mapping is done for a field with the key "sku".

public addSetting(array $setting):void

Adds a setting to the templates. Settings create components in the UI of catalogues which use this template. The components will provide data for the export in accordance with the user input in the catalogue. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
array $setting
public getSettings():array

Returns the settings of a template.

public setMetaInfo(array $meta):void

Sets the meta info for a template. Meta info is used to provide data which has to be known when working with the template. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
array $meta
public getMetaInfo():array

Returns the meta info of a template.

public isPreviewable():bool

Determines if this template supports preview exports

public allowPreview(bool $isPreviewable):void

Used to activate / deactivate the possibility to export previews through this template

Parameters
bool $isPreviewable
public hasRuntimeConfig():bool
public hasResultConverter():bool
public getRuntimeConfig():CatalogRuntimeConfigContract
public getResultConverter():CatalogResultConverterContract
public boot(CatalogTemplateProviderContract
 $provider):void

Fills the template via the given catalogue template provider. This method is called by the template container and should not be called manually.

Parameters
CatalogTemplateProviderContract $provider
public isBooted():bool

Returns the current boot state of the template.

public translatedToArray(string $language):array
Parameters
string $language
public toArray():array

Get the instance as an array.

public jsonSerialize():void

TemplateRepositoryContract

The TemplateRepositoryContract is the interface for the template repository. It allows to retrieve templates and their mappings.

Namespace

Plenty\Modules\Catalog\Contracts

Methods

public getTemplates():array

Get list of templates

public getTemplate(string $id, string $data):array

Get template

Parameters
string $id
string $data
public getMappings(string $id):array

Get list of mappings

Parameters
string $id
public getMapping(string $id, string $mappingId):array

Get mapping

Parameters
string $id
string $mappingId
public getMappingData(string $id, string $mappingId, string $parentId = null):array

Get mapping data

Parameters
string $id
string $mappingId
string $parentId
public getMappingDataById(string $id, string $mappingId, string $dataId):array

Get mapping data by id

Parameters
string $id
string $mappingId
string $dataId
public test(string $id):void

Test export of a catalog

Parameters
string $id
public getAllMappings(string $id):array

Get all mappings

Parameters
string $id

DataProviders

BaseDataProvider

The BaseDataProvider is used to define a section of simple mappings in the catalogue. A simple mapping refers to the assignment of a value in the plentymarkets system or a manually predefined value to a specific key. E.g. mapping the value of a specific text property to the key 'description'.

Namespace

Plenty\Modules\Catalog\DataProviders

Methods

public getRows():array
public setTemplate(TemplateContract
 $template):void
Parameters
TemplateContract $template
public setMapping(array $mapping):void
Parameters
array $mapping

KeyDataProvider

The KeyDataProvider is used to define a section of a complex mapping in the catalogue. A complex mapping refers to the assignment of a value from a predefined list of possible values to a key if a specific requirement is met. E.g. put the value 'awesomeBrand' into the key 'brand', if manufacturer 'awesomeManufacturer' is linked to a variation.

Namespace

Plenty\Modules\Catalog\DataProviders

Methods

public getKey():string
public getRows():array
public setTemplate(TemplateContract
 $template):void
Parameters
TemplateContract $template
public setMapping(array $mapping):void
Parameters
array $mapping

NestedKeyDataProvider

The NestedKeyDataProvider is used to define a section of a complex mapping in the catalogue. It is specifically used if the list of available values contains nested values. E.g. a list of categories with sub-categories.

Namespace

Plenty\Modules\Catalog\DataProviders

Methods

public getKey():string
public getNestedRows($parentId):array
Parameters
$parentId
public getMetaData():void
public getNestedData(string $parentId, string $query = "", array $meta = []):array
Parameters
string $parentId
string $query
array $meta
public getRows():array
public setTemplate(TemplateContract
 $template):void
Parameters
TemplateContract $template
public setMapping(array $mapping):void
Parameters
array $mapping
public getDataByValue(string $id):array

Returns a specific value of the nested data determined by its id.

Parameters
string $id

Helpers

ContentTypeHelper

Provides a list of valid content types that can be returned in a CatalogResultConverter

Namespace

Plenty\Modules\Catalog\Helpers

Methods

public static isValidType(string $type):bool

Checks wether a given type is valid as return type in a CatalogResultConverter

Parameters
string $type

Models

Catalog

The catalog model - stores on S3

Namespace

Plenty\Modules\Catalog\Models

Properties

Type Name Description
array data Contains the mappings and template settings
array settings Contains the settings
string name The name of the catalogue
string template The id of the template that was used to create the catalogue
string id The id of the catalogue
bool active Determines whether a catalogue can be exported
bool showMandatoryFields Determines if only the mandatory fields should be displayed in the catalogue UI
string updatedAt The updated at date in W3C
string createdAt The created at date in W3C

Methods

public toArray()

Returns this model as an array.

CatalogExportResult

The CatalogExportResult represents the exported data in a specific catalogue export. It implements the Iterator interface and can therefore be used in a foreach loop to retrieve the different pages of the export data.

Namespace

Plenty\Modules\Catalog\Models

Methods

public toArray()

Returns this model as an array.

Templates

BaseTemplateProvider

The BaseTemplateProvider is the abstract class that should be used to implement a template provider.

Namespace

Plenty\Modules\Catalog\Templates

Methods

public getMappings():array

Returns the different mapping sections including the information which data provider fills them. Each entry in the array represents a section of the catalogue UI.

public getFilter():array

Returns the filters that will be applied in each export of templates that will be booted by this provider.

public getPreMutators():array

Returns the callback functions that will be applied to the raw data (so before the mapping occurs) of each item in the export. Every callback function will receive an array of the raw item data and should return this array with the changes that should be applied (e.g. function (array $item){ --your code-- return $item}).

public getPostMutators():array

Returns the callback functions that will be applied to the mapped data of each item in the export. Every callback function will receive an array of the mapped item data und should return this array with the changes that should be applied (e.g. function (array $item){ --your code-- return $item}).

public getSkuCallback():callable

Returns a callback function that is called if a field with the specific key "sku" got mapped. The function will receive the value that got mapped, the raw data array of this item and the type of the mapped source. It should return the new value (e.g. function ($value, array $item, $mappingType){ --your code-- return $value})).

public getSettings():array

Returns an array of settings that will be displayed in the UI of each catalogue with a template that uses this provider. The selected values for all those settings can then be used in the export.

public getMetaInfo():array

Returns an array of meta information which can be used to forward information to the export which could otherwise not be received.

Template

Templates are used to define a schema for the creation of catalogues.

Namespace

Plenty\Modules\Catalog\Templates

Methods

public getMappings():array

Returns the mappings of a template.

public addMapping(array $section):void

Adds a mapping to the template. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
array $section
public addMutator(callable $callback):void

Deprecated!

Use Plenty\Modules\Catalog\Contracts\TemplateContract::addPreMutator or Plenty\Modules\Catalog\Contracts\TemplateContract::addPreMutator instead.
Parameters
callable $callback
public getMutators():array

Deprecated!

Use Plenty\Modules\Catalog\Contracts\TemplateContract::getPreMutators or Plenty\Modules\Catalog\Contracts\TemplateContract::getPostMutators instead.
public addPreMutator(callable $callback):void

Adds a pre mutator to the template. Pre mutators are applied to the export data before the mapping occurs. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
callable $callback
public addPostMutator(callable $callback):void

Adds a post mutator to the template. Post mutators are applied to the export data once the mapping occurred. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
callable $callback
public getFilter():array

Returns the filters of the template.

public addFilter(array $filter):void

Adds a filter to the template. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
array $filter
public getPreMutators():array

Returns the pre mutators of the template.

public getPostMutators():array

Returns the post mutators of the template.

public setSkuCallback(callable $callback):void

Defines the callback function that will be called after the mapping is done for a field with the key "sku".

Parameters
callable $callback
public getSkuCallback():callable

Returns the callback function that will be called after the mapping is done for a field with the key "sku"

public addSetting(array $setting):void

Adds a setting to the templates. Settings create components in the UI of catalogues which use this template. The components will provide data for the export in accordance with the user input in the catalogue. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
array $setting
public getSettings():array

Returns the settings of a template.

public setMetaInfo(array $meta):void

Sets the meta info for a template. Meta info is used to provide data which has to be known when working with the template. If possible, don't use this directly and let it be handled by the catalogue template provider.

Parameters
array $meta
public getMetaInfo():void
public getName():string
public getExportType():string
public getType():string
public translatedToArray(string $language):array
Parameters
string $language
public toArray():void
public jsonSerialize():void
public getIdentifier():string
public getFormatSettings():array
public getExportSettings():array
public isPreviewable():bool
public allowPreview(bool $isPreviewable):void
Parameters
bool $isPreviewable
public getRuntimeConfig():CatalogRuntimeConfigContract
public getResultConverter():CatalogResultConverterContract
public hasRuntimeConfig():bool
public hasResultConverter():bool
public boot(CatalogTemplateProviderContract
 $provider):void
Parameters
CatalogTemplateProviderContract $provider
public isBooted():bool