Skip to content

Commit

Permalink
fix: use 'stepQuantitiy' instead of 'stepOrderQuantity' to fetch the …
Browse files Browse the repository at this point in the history
…correct data in product listings (#1432)

* 'stepOrderQuantity' replaced with 'stepQuantitiy'
* product detail still only returns 'stepOrderQuantity' that has to be used and mapped internally
* internally the PWA now uses the name 'stepQuantity'
---------

Co-authored-by: Stefan Hauke <s.hauke@intershop.de>
  • Loading branch information
DilaraGueler and shauke authored May 17, 2023
1 parent 6a1c272 commit bd20419
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/app/core/facades/product-context.facade.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('Product Context Facade', () => {
completenessLevel: ProductCompletenessLevel.Detail,
minOrderQuantity: 10,
maxOrderQuantity: 100,
stepOrderQuantity: 10,
stepQuantity: 10,
available: false,
readyForShipmentMin: 0,
readyForShipmentMax: 2,
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('Product Context Facade', () => {
completenessLevel: ProductCompletenessLevel.Detail,
minOrderQuantity: 10,
maxOrderQuantity: 100,
stepOrderQuantity: 10,
stepQuantity: 10,
available: true,
readyForShipmentMin: 0,
readyForShipmentMax: 2,
Expand Down Expand Up @@ -768,7 +768,7 @@ describe('Product Context Facade', () => {
completenessLevel: ProductCompletenessLevel.Detail,
minOrderQuantity: 10,
maxOrderQuantity: 100,
stepOrderQuantity: 10,
stepQuantity: 10,
available: true,
readyForShipmentMin: 0,
readyForShipmentMax: 2,
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/facades/product-context.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class ProductContextFacade extends RxState<ProductContext> implements OnD
this.connect(
'stepQuantity',
this.select('product').pipe(
map(product => product?.stepOrderQuantity || 1),
map(product => product?.stepQuantity || 1),
distinctUntilChanged()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exports[`Product Mapper fromStubData should construct a stub when supplied with
"roundedAverageRating": 0,
"shortDescription": "EasyShare M552, 14MP, 6.858 cm (2.7 ") LCD, 4x, 28mm, HD 720p, Black",
"sku": "7912057",
"stepOrderQuantity": undefined,
"stepQuantity": undefined,
"type": "Product",
}
`;
3 changes: 2 additions & 1 deletion src/app/core/models/product/product.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export interface ProductData {
productMasterSKU?: string;
minOrderQuantity: number;
maxOrderQuantity?: number;
stepOrderQuantity?: number;
stepOrderQuantity?: number; // property name used by the product detail response (will be deprecated)
stepQuantity?: number; // property name used in product list response (will become the consistent name)
packingUnit: string;

variationAttributeValuesExtended?: VariationAttributeData[];
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/models/product/product.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class ProductMapper {
longDescription: undefined,
minOrderQuantity: retrieveStubAttributeValue<{ value: number }>(data, 'minOrderQuantity')?.value,
maxOrderQuantity: retrieveStubAttributeValue<{ value: number }>(data, 'maxOrderQuantity')?.value,
stepOrderQuantity: retrieveStubAttributeValue<{ value: number }>(data, 'stepOrderQuantity')?.value,
stepQuantity: retrieveStubAttributeValue<{ value: number }>(data, 'stepQuantity')?.value,
packingUnit: retrieveStubAttributeValue(data, 'packingUnit'),
attributeGroups: data.attributeGroup && mapAttributeGroups(data),
readyForShipmentMin: undefined,
Expand All @@ -161,7 +161,7 @@ export class ProductMapper {
available: this.calculateAvailable(data.availability, data.inStock),
minOrderQuantity: data.minOrderQuantity,
maxOrderQuantity: data.maxOrderQuantity,
stepOrderQuantity: data.stepOrderQuantity,
stepQuantity: data.stepOrderQuantity,
packingUnit: data.packingUnit,
availableStock: data.availableStock,
attributes: data.attributeGroups?.PRODUCT_DETAIL_ATTRIBUTES?.attributes || data.attributes || [],
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/models/product/product.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Product {
availableStock?: number;
minOrderQuantity: number;
maxOrderQuantity: number;
stepOrderQuantity: number;
stepQuantity: number;
attributes: Attribute[];
attributeGroups?: { [id: string]: AttributeGroup };
attachments?: Attachment[];
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/products/products-list-attributes.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default 'sku,availability,manufacturer,image,minOrderQuantity,maxOrderQuantity,stepOrderQuantity,inStock,promotions,packingUnit,mastered,productMaster,productMasterSKU,roundedAverageRating,retailSet,defaultCategory';
export default 'sku,availability,manufacturer,image,minOrderQuantity,maxOrderQuantity,stepQuantity,inStock,promotions,packingUnit,mastered,productMaster,productMasterSKU,roundedAverageRating,retailSet,defaultCategory';

0 comments on commit bd20419

Please sign in to comment.