Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: localized product attributes #107

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/app/core/models/product/product.mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ describe('Product Mapper', () => {
expect(product.type).toEqual('RetailSet');
expect(ProductHelper.isRetailSet(product)).toBeTrue();
});

it('should return attributes or detailed product attributes when PRODUCT_DETAIL_ATTRIBUTES enabled', () => {
const p1: Product = productMapper.fromData({
sku: '1',
attributes: [{ name: 'Graphics', type: 'String', value: 'NVIDIA Quadro K2200' }],
} as ProductData);
const p2: Product = productMapper.fromData(({
sku: '1',
attributes: [{ name: 'Graphics', type: 'String', value: 'NVIDIA Quadro K2200' }],
attributeGroups: {
PRODUCT_DETAIL_ATTRIBUTES: {
attributes: [{ name: 'Grafikkarte', type: 'String', value: 'NVIDIA Quadro K2200' }],
},
},
} as unknown) as ProductData);
expect(p1).toBeTruthy();
expect(p1.attributes).toEqual([{ name: 'Graphics', type: 'String', value: 'NVIDIA Quadro K2200' }]);
expect(p2).toBeTruthy();
expect(p2.attributes).toEqual([{ name: 'Grafikkarte', type: 'String', value: 'NVIDIA Quadro K2200' }]);
});
});

describe('fromStubData', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/app/core/models/product/product.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ export class ProductMapper {
minOrderQuantity: data.minOrderQuantity || 1,
packingUnit: data.packingUnit,
maxOrderQuantity: data.maxOrderQuantity || 100,
attributes: data.attributes,
attributes:
(data.attributeGroups &&
data.attributeGroups.PRODUCT_DETAIL_ATTRIBUTES &&
data.attributeGroups.PRODUCT_DETAIL_ATTRIBUTES.attributes) ||
data.attributes,
attributeGroups: data.attributeGroups,
images: this.imageMapper.fromImages(data.images),
listPrice: filterPrice(data.listPrice),
Expand Down