Skip to content

Commit

Permalink
Add search weight in fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran committed Oct 9, 2023
1 parent 95a8172 commit f1dd623
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Fixture/Factory/SearchableFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protected function configureOptions(OptionsResolver $resolver): void
->setNormalizer('option', LazyOption::findOneBy($this->productOptionRepository, 'code'))
->setDefault('filterable', false)
->setDefault('searchable', false)
->setDefault('search_weight', 1)
;
}

Expand All @@ -79,6 +80,7 @@ public function create(array $options = []): SearchableInterface
$object = $this->getSearchableObject($options);
$object->setFilterable(((bool) $options['filterable']) ?? false);
$object->setSearchable(((bool) $options['searchable']) ?? false);
$object->setSearchWeight(((int) $options['search_weight']) ?? 1);

return $object;
}
Expand Down
1 change: 1 addition & 0 deletions src/Fixture/SearchableFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected function configureResourceNode(ArrayNodeDefinition $resourceNode): voi
->scalarNode('option')->end()
->booleanNode('filterable')->defaultValue(true)->end()
->booleanNode('searchable')->defaultValue(true)->end()
->integerNode('search_weight')->defaultValue(1)->end()
;
}
}
4 changes: 4 additions & 0 deletions src/Resources/config/sylius/fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ sylius_fixtures:
attribute: 'cap_collection'
filterable: true
searchable: true
search_weight: 5
dress_collection:
attribute: 'dress_collection'
filterable: true
searchable: true
search_weight: 4
dress_height:
option: 'dress_height'
filterable: true
searchable: true
search_weight: 3
dress_size:
option: 'dress_size'
filterable: true
searchable: true
search_weight: 2

0 comments on commit f1dd623

Please sign in to comment.