Skip to content

Commit

Permalink
Add attributes for fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Apr 16, 2024
1 parent 7aa02f1 commit d780e23
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Parser/ElasticsearchProductDocumentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,15 @@ public function parse(array $document): ProductResponseInterface
$productAttributeValue->setAttribute($productAttribute);
$productAttributeValue->setLocaleCode($localeCode);
$productAttributeValue->setSubject($productResponse);
$productAttributeValue->setValue(reset($esProductAttributeValue['values']));
$firstValue = reset($esProductAttributeValue['values']);
if ($productAttribute->getStorageType() === AttributeValueInterface::STORAGE_DATETIME ||
$productAttribute->getStorageType() === AttributeValueInterface::STORAGE_DATE
) {
$firstValue = new DateTime((string) $firstValue);
} elseif ($productAttribute->getStorageType() === AttributeValueInterface::STORAGE_JSON) {
$firstValue = [$firstValue];
}
$productAttributeValue->setValue($firstValue);
$productResponse->addAttribute($productAttributeValue);
}
}
Expand Down
126 changes: 126 additions & 0 deletions tests/Application/config/fixtures/dress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,112 @@ sylius_fixtures:
code: 'dress_material'
type: 'text'

-
name: 'Dress text not translatable'
code: 'dress_text_not_translatable'
translatable: false
type: 'text'

-
name: 'Dress textarea not translatable'
code: 'dress_textarea_not_translatable'
translatable: false
type: 'textarea'

-
name: 'Dress textarea translatable'
code: 'dress_textarea_translatable'
translatable: true
type: 'textarea'

-
name: 'Checkbox not translatable'
code: 'dress_checkbox_not_translatable'
translatable: false
type: 'checkbox'

-
name: 'Checkbox translatable'
code: 'dress_checkbox_translatable'
translatable: true
type: 'checkbox'

-
name: 'Integer translatable'
code: 'dress_integer_translatable'
type: 'integer'
translatable: true

-
name: 'Length'
code: 'length'
type: 'integer'
translatable: false

-
name: 'Percent not translatable'
code: 'dress_percent_not_translatable'
translatable: false
type: 'percent'

-
name: 'Percent translatable'
code: 'dress_percent_translatable'
translatable: true
type: 'percent'

-
name: 'Datetime not translatable'
code: 'dress_datetime_not_translatable'
translatable: false
type: 'datetime'

-
name: 'Datetime translatable'
code: 'dress_datetime_translatable'
translatable: true
type: 'datetime'

-
name: 'Date not translatable'
code: 'dress_date_not_translatable'
translatable: false
type: 'date'

-
name: 'Date translatable'
code: 'dress_date_translatable'
translatable: true
type: 'date'

-
name: 'Select not translatable'
code: 'dress_select_not_translatable'
translatable: false
type: 'select'
configuration:
multiple: false
min: null
max: null
choices:
dress_select_not_translatable_1:
en_US: 'Dress select not translatable value 1'
it_IT: 'Vestito selezione non traducibile valore 1'

-
name: 'Select translatable'
code: 'dress_select_translatable'
translatable: true
type: 'select'
configuration:
multiple: false
min: null
max: null
choices:
dress_select_translatable_1:
en_US: 'Dress select translatable value 1'
it_IT: 'Vestito selezione traducibile valore 1'

dress_option:
name: product_option
options:
Expand Down Expand Up @@ -87,6 +187,20 @@ sylius_fixtures:
dress_brand: 'You are breathtaking'
dress_collection: 'Sylius Summer 2019'
dress_material: '100% polyester'
dress_text_not_translatable: 'Abacaba'
dress_textarea_not_translatable: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nec purus feugiat, vestibulum nunc sit amet'
dress_textarea_translatable: 'Qui minus atque ut odio commodi qui aperiam temporibus qui consectetur atque non molestiae sapiente in vero incidunt. Est incidunt rerum est quibusdam ipsa et quae labore a voluptas autem vel tenetur quisquam eos dignissimos quam.'
dress_checkbox_translatable: true
dress_checkbox_not_translatable: false
dress_integer_translatable: 10
dress_percent_translatable: 0.10
dress_percent_not_translatable: 0.12
dress_datetime_not_translatable: '2019-01-01T12:50:00+00:00'
dress_datetime_translatable: '2019-01-01T12:50:00+00:00'
dress_date_not_translatable: '2019-01-01'
dress_date_translatable: '2019-01-01'
dress_select_not_translatable: ['dress_select_not_translatable_1']
dress_select_translatable: ['dress_select_translatable_1']
product_options:
- 'dress_size'
- 'dress_height'
Expand All @@ -106,6 +220,12 @@ sylius_fixtures:
dress_brand: 'You are breathtaking'
dress_collection: 'Sylius Summer 2019'
dress_material: '100% wool'
dress_text_not_translatable: 'Terasdf'
dress_textarea_not_translatable: 'Sed vero accusamus sit ipsa consequatur ad sint ipsam cum veniam cupiditate est quia neque ab autem tenetur. Et expedita velit est quia quaerat ut quas aliquam et animi illum. Nam quisquam odit aut adipisci internos et dolor consectetur est sapiente illo est nobis reprehenderit hic mollitia beatae ad excepturi aliquid.'
dress_textarea_translatable: 'Eos repellat facilis hic dolores dolorum ut sint harum eos quos optio ut totam impedit sit autem repudiandae. Qui distinctio quasi rem vero laborum et officiis ipsum eum reiciendis nihil.'
dress_checkbox_translatable: true
dress_checkbox_not_translatable: true
dress_integer_translatable: 20
product_options:
- 'dress_size'
- 'dress_height'
Expand All @@ -126,6 +246,12 @@ sylius_fixtures:
dress_collection: 'Sylius Summer 2019'
dress_material: '100% polyester'
length: 100
dress_text_not_translatable: 'Rienac'
dress_textarea_not_translatable: 'Ea voluptas voluptate rem architecto laboriosam est aperiam galisum et iste natus est quos dolorum ex culpa repudiandae qui suscipit quia. Ut rerum expedita et omnis rerum eos dolores quia ab sint cumque.'
dress_textarea_translatable: 'Cum beatae illum quo velit quis non culpa sunt est provident tenetur et corporis sunt nam ipsum dolor. Et animi enim ad dolorum ipsum ut laborum nobis sit neque rerum sed illo error non quod quaerat? Sed culpa blanditiis ut quod assumenda et veritatis officiis est suscipit facilis.'
dress_checkbox_translatable: false
dress_checkbox_not_translatable: false
dress_integer_translatable: 18
product_options:
- 'dress_size'
- 'dress_height'
Expand Down

0 comments on commit d780e23

Please sign in to comment.