Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.

You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page

TypeaheadProductCollectionType

This form class allows you to select a product, with or without an attribute field.

Type options

Option Type Default value Description

Code example

$builder->add('related_products', TypeaheadProductCollectionType::class, [
    'remote_url' => $this->context->getLegacyAdminLink('AdminProducts', true, ['ajax' => 1, 'action' => 'productsList', 'forceJson' => 1, 'disableCombination' => 1, 'exclude_packs' => 0, 'excludeVirtuals' => 0, 'limit' => 20]) . '&q=%QUERY',
    'mapping_value' => 'id',
    'mapping_name' => 'name',
    'placeholder' => $this->translator->trans('Search and add a related product', [], 'Admin.Catalog.Help'),
    'template_collection' => '<span class="label">%s</span><i class="material-icons delete">clear</i>',
    'required' => false,
    'label' => $this->translator->trans('Accessories', [], 'Admin.Catalog.Feature'),
])

Preview example

TypeaheadProductCollectionType rendered in form using textarea