PrestaShop Developer Conference
PrestaShop Developer Conference
Paris, France - November 6, 2024
Let's talk code, commerce and open source.

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