6 declare(strict_types=1);
15 as FieldTypeConverterInterface;
17 as IndexTypeConverterInterface;
32 private $categoryList;
39 private $groupRepository;
46 private $searchCriteriaBuilder;
51 private $fieldTypeConverter;
56 private $indexTypeConverter;
61 private $attributeAdapterProvider;
66 private $fieldNameResolver;
78 FieldTypeConverterInterface $fieldTypeConverter,
79 IndexTypeConverterInterface $indexTypeConverter,
83 FieldNameResolver $fieldNameResolver,
88 $this->fieldTypeConverter = $fieldTypeConverter;
89 $this->indexTypeConverter = $indexTypeConverter;
91 $this->fieldNameResolver = $fieldNameResolver;
92 $this->attributeAdapterProvider = $attributeAdapterProvider;
98 public function getFields(array $context = []): array
103 $positionAttribute = $this->attributeAdapterProvider->getByAttributeCode(
'position');
104 $categoryNameAttribute = $this->attributeAdapterProvider->getByAttributeCode(
'category_name');
106 $categoryPositionKey = $this->fieldNameResolver->getFieldName(
110 $categoryNameKey = $this->fieldNameResolver->getFieldName(
111 $categoryNameAttribute,
114 $allAttributes[$categoryPositionKey] = [
115 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING),
116 'index' => $this->indexTypeConverter->convert(IndexTypeConverterInterface::INTERNAL_NO_INDEX_VALUE)
118 $allAttributes[$categoryNameKey] = [
119 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING),
120 'index' => $this->indexTypeConverter->convert(IndexTypeConverterInterface::INTERNAL_NO_INDEX_VALUE)
124 $groups = $this->groupRepository->getList(
$searchCriteria)->getItems();
125 $priceAttribute = $this->attributeAdapterProvider->getByAttributeCode(
'price');
126 foreach ($groups as
$group) {
127 $groupPriceKey = $this->fieldNameResolver->getFieldName(
129 [
'customerGroupId' =>
$group->getId(),
'websiteId' => $context[
'websiteId']]
131 $allAttributes[$groupPriceKey] = [
132 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_FLOAT),
137 return $allAttributes;
getFields(array $context=[])
__construct(FieldTypeConverterInterface $fieldTypeConverter, IndexTypeConverterInterface $indexTypeConverter, GroupRepositoryInterface $groupRepository, SearchCriteriaBuilder $searchCriteriaBuilder, CategoryListInterface $categoryList, FieldNameResolver $fieldNameResolver, AttributeProvider $attributeAdapterProvider)