fix : put attibute value directl in product
This commit is contained in:
@@ -161,17 +161,18 @@ class ProductService {
|
||||
}
|
||||
|
||||
// Fetch the attribute values from the database
|
||||
const attributeValues = await this.attributeValueRepo.model.find({
|
||||
_id: { $in: attribute.values },
|
||||
});
|
||||
// const attributeValues = await this.attributeValueRepo.model.find({
|
||||
// _id: { $in: attribute.values },
|
||||
// });
|
||||
|
||||
// Check if any attribute values were found
|
||||
if (attributeValues.length === 0) {
|
||||
throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
||||
}
|
||||
// if (attributeValues.length === 0 ) {
|
||||
// throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
||||
// }
|
||||
|
||||
// Map the values to their text value
|
||||
const selectedValues = attributeValues.map((val: IAttributeValue) => val.text);
|
||||
// const selectedValues = attributeValues.map((val: IAttributeValue) => val.text);
|
||||
const selectedValues = attribute.values.map((val) => String(val));
|
||||
|
||||
specifications.push({
|
||||
title: attributeDetails.title,
|
||||
@@ -279,17 +280,17 @@ class ProductService {
|
||||
}
|
||||
|
||||
// Fetch the attribute values from the database
|
||||
const attributeValues = await this.attributeValueRepo.model.find({
|
||||
_id: { $in: attribute.values },
|
||||
});
|
||||
// const attributeValues = await this.attributeValueRepo.model.find({
|
||||
// _id: { $in: attribute.values },
|
||||
// });
|
||||
|
||||
// Check if any attribute values were found
|
||||
if (attributeValues.length === 0) {
|
||||
throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
||||
}
|
||||
// if (attributeValues.length === 0) {
|
||||
// throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
||||
// }
|
||||
|
||||
// Map the values to their text value
|
||||
const selectedValues = attributeValues.map((val: IAttributeValue) => val.text);
|
||||
const selectedValues = attribute.values.map((val) => String(val));
|
||||
|
||||
specifications.push({
|
||||
title: attributeDetails.title,
|
||||
@@ -423,15 +424,15 @@ class ProductService {
|
||||
throw new BadRequestError(AttributeMessage.AttributeIdIsIncorrect);
|
||||
}
|
||||
|
||||
const attributeValues = await this.attributeValueRepo.model.find({
|
||||
_id: { $in: attribute.values },
|
||||
});
|
||||
// const attributeValues = await this.attributeValueRepo.model.find({
|
||||
// _id: { $in: attribute.values },
|
||||
// });
|
||||
|
||||
if (attributeValues.length === 0) {
|
||||
throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
||||
}
|
||||
// if (attributeValues.length === 0) {
|
||||
// throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
||||
// }
|
||||
|
||||
const selectedValues = attributeValues.map((val: IAttributeValue) => val.text);
|
||||
const selectedValues = attribute.values.map((val) => String(val));
|
||||
|
||||
specifications.push({
|
||||
title: attributeDetails.title,
|
||||
|
||||
Reference in New Issue
Block a user