I have a product catalog. There are:
Dzial.php - category page PodDzial.php - subcategory page
Produkt.php - product - DataObjects which belong to PodDzial.php
Kategoria.php - type of product- which belong to PodDzial (has_one) and to Produkt (has_many)
Marka.php - brand of product- which belong to Dzial (has_one) and to Produkt (has_many)
I work on custom search on PodDzial page.
There is code which don't work:
public function getDefaultSearchContext() {
$fields = new FieldList(
TextField::create('PodDzial', 'PodDzial')->setValue($this->PodDzialID) ,
DropdownField::create(
'MarkaID',
'Marka',
Marka::get()->map('ID','Title')
)->setEmptyString('--Wybierz marke--') ,
DropdownField::create(
'KategoriaID',
'Kategoria',
Kategoria::get()->filter(array('PodDzialID' => $this->PodDzialID))->map('ID','Title')
)->setEmptyString('--Wybierz kategorie--')
);
$filters = array(
'PodDzialID' => new ExactMatchFilter('PodDzialID') ,
'MarkaID' => new ExactMatchFilter('MarkaID'),
'KategoriaID' => new ExactMatchFilter('KategoriaID')
);
return new SearchContext(
$this->class,
$fields,
$filters
);
}
Marka's field shows all Marka even from other categories. Kategoria show nothing. This same code for Kategoria works propertly in function getCMSFields().
Anyone can help?