Skip to content

Add ability to filter selector collections (e.g. hide inactive products) #322

@Daaaaad

Description

@Daaaaad

The selector field type only accepts a string (e.g. 'Product', 'Category').
AdminThemeManagerController::getCollectionAction() then creates a raw PrestaShopCollection:

$psCollection = new PrestaShopCollection($collection, $id_lang);

No extra filter is applied, so inactive / offline products appear in the dropdown.
On production sites this often leads to blocks displaying unavailable products.

Current behaviour

'product' => [
    'type'       => 'selector',
    'collection' => 'Product',
    'selector'   => '{id} - {name}',
],

Typing any query shows both active and inactive products.

Expected / requested behaviour

  • Either: built-in filter so only active products are returned (active = 1).
  • Or: accept custom conditions, e.g.
'options' => [
    'where' => 'active = 1 AND visibility IN ("both","catalog")'
]

Thanks for considering!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions