Skip to content

Commit

Permalink
馃Ч remove "image" index name from grouped images (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianzimmermann committed Aug 31, 2023
1 parent ec58b34 commit de760d6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 35 deletions.
48 changes: 22 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,30 @@ This package will group the image sets by name. Example:

```
"groupedImages": {
"setName1": {
"images": [
{
"externalUrlSmall": "https:\/\/...",
"externalUrlLarge": "https:\/\/...",
"sortOrder": 5
},
{
"externalUrlSmall": "https:\/\/...",
"externalUrlLarge": "https:\/\/...",
"sortOrder": 10
},
{
"externalUrlSmall": "https:\/\/...",
"externalUrlLarge": "https:\/\/...",
"sortOrder": 15
}
]
"setName1": [
{
"externalUrlSmall": "https:\/\/...",
"externalUrlLarge": "https:\/\/...",
"sortOrder": 5
},
"setName2": {
"images": [
{
"externalUrlSmall": "https:\/\/...",
"externalUrlLarge": "https:\/\/...",
"sortOrder": 0
}
]
{
"externalUrlSmall": "https:\/\/...",
"externalUrlLarge": "https:\/\/...",
"sortOrder": 10
},
{
"externalUrlSmall": "https:\/\/...",
"externalUrlLarge": "https:\/\/...",
"sortOrder": 15
}
],
"setName2": [
{
"externalUrlSmall": "https:\/\/...",
"externalUrlLarge": "https:\/\/...",
"sortOrder": 0
}
]
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function prepareImageData(array $product): array
$key = lcfirst(str_replace('_', '', ucwords($key, '_')));

foreach ($images as $image) {
$groupedImages[$key]['images'][] = (new RestCatalogSearchProductImageTransfer())->fromArray($image, true)->toArray();
$groupedImages[$key][] = (new RestCatalogSearchProductImageTransfer())->fromArray($image, true)->toArray();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
xsi:schemaLocation="spryker:transfer-01 https://static.spryker.com/transfer-01.xsd">

<transfer name="RestCatalogSearchAbstractProducts">
<property name="groupedImages" type="RestCatalogSearchGroupedProductImages[]" associative="true" singular="groupedImage"/>
</transfer>

<transfer name="RestCatalogSearchGroupedProductImages">
<property name="images" type="RestCatalogSearchProductImage[]" associative="true" singular="images"/>
<property name="groupedImages" type="array" associative="true" singular="groupedImage"/>
</transfer>

<transfer name="RestCatalogSearchProductImage">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public function testFormatSearchResult(): void

static::assertArrayHasKey(ProductImageGroupMapExpanderPlugin::KEY, $data[0]);
static::assertArrayHasKey('frontView', $data[0][ProductImageGroupMapExpanderPlugin::KEY]);
static::assertCount(1, $data[0][ProductImageGroupMapExpanderPlugin::KEY]['frontView']['images']);
static::assertCount(1, $data[0][ProductImageGroupMapExpanderPlugin::KEY]['frontView']);
static::assertArrayHasKey('topView', $data[0][ProductImageGroupMapExpanderPlugin::KEY]);
static::assertCount(2, $data[0][ProductImageGroupMapExpanderPlugin::KEY]['topView']['images']);
static::assertEquals(99, $data[0][ProductImageGroupMapExpanderPlugin::KEY]['topView']['images'][1]['sort_order']);
static::assertCount(2, $data[0][ProductImageGroupMapExpanderPlugin::KEY]['topView']);
static::assertEquals(99, $data[0][ProductImageGroupMapExpanderPlugin::KEY]['topView'][1]['sort_order']);
}
}

0 comments on commit de760d6

Please sign in to comment.