ProductCategoryPickerTrait
Pickers of eshop categories: - {@see productCategoryParentPicker()}: single field, the parent category (self-reference: excludes the edited category and its whole subtree); - {@see productCategoryMultiPicker()}: multiplier row, M:N assignment of a product to categories (the categories stay on `Product`).
The label is the name (translations.name) in the current language. The suggest and the
modal use the show grid of :Admin:Eshop:ProductCategory. Requires
$this->productCategoryManager.
Table of Contents
Methods
- productCategoryMultiPicker() : PickerConfig
- Category picker for a multiplier row (M:N product to category), like {@see \App\UI\Admin\Bazaar\Presenters\Traits\Forms\AdvertCategoryFieldsTrait::categoryMultiPicker()}.
- productCategoryParentPicker() : PickerConfig
- Parent category picker (single field, self-reference), like {@see \App\UI\Admin\Blog\Presenters\Traits\Pickers\CategoryPickerTrait::categoryParentPicker()}.
- categoryName() : string
- Returns the category name in the current language (falls back to the first non-empty one).
- resolveCategoryLabel() : string|null
- suggestCategories() : array<int, array{id: int, label: string}>
- Suggests categories by a LIKE match on the name, optionally without the excluded node and its whole subtree (parent self-reference).
Methods
productCategoryMultiPicker()
Category picker for a multiplier row (M:N product to category), like {@see \App\UI\Admin\Bazaar\Presenters\Traits\Forms\AdvertCategoryFieldsTrait::categoryMultiPicker()}.
protected
productCategoryMultiPicker([string $container = 'categories' ][, string $targetField = 'categoryId' ][, string $displayField = 'category' ][, string $formName = 'editForm' ]) : PickerConfig
IMPORTANT: displayField is required in a multiplier; the label must survive the AJAX
re-render of the row, otherwise it goes empty after a row is added or removed.
Parameters
- $container : string = 'categories'
- $targetField : string = 'categoryId'
- $displayField : string = 'category'
- $formName : string = 'editForm'
Return values
PickerConfigproductCategoryParentPicker()
Parent category picker (single field, self-reference), like {@see \App\UI\Admin\Blog\Presenters\Traits\Pickers\CategoryPickerTrait::categoryParentPicker()}.
protected
productCategoryParentPicker([string $formName = 'editForm' ][, string $targetField = 'parentId' ][, int|null $excludeId = null ][, int|null $excludeLft = null ][, int|null $excludeRgt = null ]) : PickerConfig
The edited category and its descendants must not become its parent, so they are excluded
from the suggest (lft/rgt) and from the modal (pickerExclude plus subtree bounds).
Parameters
- $formName : string = 'editForm'
- $targetField : string = 'parentId'
- $excludeId : int|null = null
-
id of the edited category (self-reference)
- $excludeLft : int|null = null
-
lft of the edited category (subtree exclusion)
- $excludeRgt : int|null = null
-
rgt of the edited category (subtree exclusion)
Return values
PickerConfigcategoryName()
Returns the category name in the current language (falls back to the first non-empty one).
private
categoryName(ProductCategory $category) : string
Parameters
- $category : ProductCategory
Return values
stringresolveCategoryLabel()
private
resolveCategoryLabel(int $id) : string|null
Parameters
- $id : int
Return values
string|nullsuggestCategories()
Suggests categories by a LIKE match on the name, optionally without the excluded node and its whole subtree (parent self-reference).
private
suggestCategories(string $query[, int|null $excludeId = null ][, int|null $excludeLft = null ][, int|null $excludeRgt = null ]) : array<int, array{id: int, label: string}>
Parameters
- $query : string
- $excludeId : int|null = null
- $excludeLft : int|null = null
- $excludeRgt : int|null = null