Skip to content
This repository has been archived by the owner on Aug 3, 2018. It is now read-only.

Commit

Permalink
Merge pull request #37 from Sylius/fix-attribute-name-translation
Browse files Browse the repository at this point in the history
[ElasticSearch] Fix attribute translation
  • Loading branch information
Arminek authored Jul 18, 2017
2 parents 6fc614d + 88441b7 commit c461c92
Show file tree
Hide file tree
Showing 15 changed files with 548 additions and 697 deletions.
6 changes: 4 additions & 2 deletions src/Factory/ProductDocumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Locale\Model\LocaleInterface;
use Sylius\Component\Product\Model\ProductAttributeTranslationInterface;
use Sylius\Component\Resource\Model\TranslationInterface;
use Sylius\Component\Taxonomy\Model\TaxonTranslationInterface;
use Sylius\ElasticSearchPlugin\Document\AttributeDocument;
use Sylius\ElasticSearchPlugin\Document\AttributeValueDocument;
use Sylius\ElasticSearchPlugin\Document\ImageDocument;
use Sylius\ElasticSearchPlugin\Document\PriceDocument;
use Sylius\ElasticSearchPlugin\Document\ProductDocument;
Expand Down Expand Up @@ -163,7 +163,9 @@ public function createFromSyliusSimpleProductModel(ProductInterface $syliusProdu
$productAttribute = new $this->attributeDocumentClass();
$productAttribute->setCode($syliusProductAttributeValue->getCode());
$productAttribute->setValue($syliusProductAttributeValue->getValue());
$productAttribute->setName($syliusProductAttributeValue->getAttribute()->getName());
/** @var ProductAttributeTranslationInterface $syliusProductAttributeTranslation */
$syliusProductAttributeTranslation = $syliusProductAttributeValue->getAttribute()->getTranslation($locale->getCode());
$productAttribute->setName($syliusProductAttributeTranslation->getName());

$productAttributes[] = $productAttribute;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/SearchControllerApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function it_shows_paginated_product_list_by_wood_attribute_and_de_DE_loca
{
$this->loadFixturesFromFile('shop.yml');

$this->client->request('GET', '/shop-api/products', ['attributes' => ['Mug material' => ['Holz']], 'locale' => 'de_DE'], [], ['ACCEPT' => 'application/json']);
$this->client->request('GET', '/shop-api/products', ['attributes' => ['Becher Material' => ['Holz']], 'locale' => 'de_DE'], [], ['ACCEPT' => 'application/json']);

$response = $this->client->getResponse();

Expand Down
193 changes: 81 additions & 112 deletions tests/Responses/Expected/first_page_of_limited_product_list_page.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"current": 1999,
"currency": "GBP"
},
"images": [
]
"images": []
}
],
"attributes": [
Expand All @@ -40,8 +39,7 @@
"value": "Wood"
}
],
"images": [
],
"images": [],
"channelCode": "WEB_GB",
"localeCode": "en_GB"
},
Expand All @@ -65,24 +63,22 @@
"current": 1999,
"currency": "GBP"
},
"images": [
]
"images": []
}
],
"attributes": [
{
"code": "MUG_COLLECTION_CODE",
"name": "Mug collection",
"name": "Becher Sammlung",
"value": "FEIERTAGSKOLLEKTION"
},
{
"code": "MUG_MATERIAL_CODE",
"name": "Mug material",
"name": "Becher Material",
"value": "Holz"
}
],
"images": [
],
"images": [],
"channelCode": "WEB_GB",
"localeCode": "de_DE"
},
Expand All @@ -105,8 +101,7 @@
"current": 2999,
"currency": "GBP"
},
"images": [
]
"images": []
}
],
"attributes": [
Expand All @@ -116,8 +111,7 @@
"value": "HOLIDAY COLLECTION"
}
],
"images": [
],
"images": [],
"channelCode": "WEB_GB",
"localeCode": "en_GB"
}
Expand All @@ -126,18 +120,13 @@
"channel": {
"state": {
"active": false,
"urlParameters": [
],
"urlParameters": [],
"name": "channel",
"options": [
]
"options": []
},
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "channel",
"choices": [
{
Expand All @@ -154,18 +143,13 @@
"taxonCode": {
"state": {
"active": false,
"urlParameters": [
],
"urlParameters": [],
"name": "taxonCode",
"options": [
]
"options": []
},
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "taxonCode",
"choices": [
{
Expand Down Expand Up @@ -218,37 +202,27 @@
"priceRange": {
"state": {
"active": false,
"urlParameters": [
],
"urlParameters": [],
"name": "priceRange",
"options": [
]
"options": []
},
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "priceRange",
"minBounds": 1999,
"maxBounds": 2999
},
"locale": {
"state": {
"active": false,
"urlParameters": [
],
"urlParameters": [],
"name": "locale",
"options": [
]
"options": []
},
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "locale",
"choices": [
{
Expand All @@ -275,85 +249,96 @@
"state": {
"active": true,
"value": 1,
"urlParameters": [
],
"urlParameters": [],
"name": "paginator",
"options": {
"limit": 3
}
},
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "paginator",
"currentPage": 1,
"totalItems": 6,
"maxPages": 20,
"itemsPerPage": 3,
"numPages": 2,
"options": [
],
"options": [],
"limit": 3
},
"search": {
"state": {
"active": false,
"urlParameters": [
],
"urlParameters": [],
"name": "search",
"options": [
]
"options": []
},
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "search"
},
"attributes": {
"state": {
"active": false,
"urlParameters": [
],
"urlParameters": [],
"name": "attributes",
"options": [
]
"options": []
},
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "attributes",
"items": [
{
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"name": "Mug collection",
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "Becher Material",
"choices": {
"Holz": {
"active": false,
"default": false,
"urlParameters": {
"attributes": {
"Becher Material": [
"Holz"
]
}
},
"label": "Holz",
"count": 1
}
}
},
{
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "Becher Sammlung",
"choices": {
"FEIERTAGSKOLLEKTION": {
"active": false,
"default": false,
"urlParameters": {
"attributes": {
"Mug collection": [
"Becher Sammlung": [
"FEIERTAGSKOLLEKTION"
]
}
},
"label": "FEIERTAGSKOLLEKTION",
"count": 2
},
}
}
},
{
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "Mug collection",
"choices": {
"HOLIDAY COLLECTION": {
"active": false,
"default": false,
Expand All @@ -370,27 +355,11 @@
}
},
{
"tags": [
],
"urlParameters": [
],
"resetUrlParameters": [
],
"tags": [],
"urlParameters": [],
"resetUrlParameters": [],
"name": "Mug material",
"choices": {
"Holz": {
"active": false,
"default": false,
"urlParameters": {
"attributes": {
"Mug material": [
"Holz"
]
}
},
"label": "Holz",
"count": 1
},
"Wood": {
"active": false,
"default": false,
Expand Down
Loading

0 comments on commit c461c92

Please sign in to comment.