fix(torob): deduplicate subtitle package size and add fresh expiry guarantee
This commit is contained in:
1 parent
06b8d6af23
commit
8bf1843b9b
2 files changed
+41
-13
No files matched your search
@@ -102,7 +102,7 @@ function buildTorobProductSpec(product: {
|
||||
const spec: Record<string, string> = {
|
||||
'برند': 'کنینا (Canina Pharma Germany)',
|
||||
'کشور سازنده': 'آلمان',
|
||||
'ضمانت': 'اصالت ۱۰۰٪ کالای آلمانی و سلامت فیزیکی',
|
||||
'ضمانت': 'اصالت ۱۰۰٪ کالای آلمانی، سلامت فیزیکی و تاریخ انقضای بهروز',
|
||||
};
|
||||
|
||||
const pet = normalizeSuitableFor(product.suitableFor);
|
||||
@@ -183,16 +183,28 @@ export class TorobController {
|
||||
const rawEn = (product.nameEn || "").trim();
|
||||
const numSize = Number(product.packageSize);
|
||||
const unit = (product.unit || "").trim();
|
||||
const sizeStr =
|
||||
numSize && numSize > 0
|
||||
? unit
|
||||
? `${numSize} ${unit}`
|
||||
: `${numSize}`
|
||||
: "";
|
||||
let subtitle = rawEn.startsWith("Canina")
|
||||
? rawEn
|
||||
: `Canina ${rawEn}`.trim();
|
||||
if (sizeStr && !subtitle.includes(sizeStr)) {
|
||||
|
||||
// Check if size is already present in subtitle
|
||||
let sizeAlreadyInSubtitle = false;
|
||||
if (numSize && numSize > 0) {
|
||||
const escapedUnit = unit.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const regexList = [
|
||||
new RegExp(`\\b${numSize}\\s*${escapedUnit}\\b`, 'i'),
|
||||
new RegExp(`\\b${numSize}${escapedUnit}\\b`, 'i'),
|
||||
new RegExp(`\\b${numSize}\\s*g(r|ram)?\\b`, 'i'),
|
||||
new RegExp(`\\b${numSize}g(r|ram)?\\b`, 'i'),
|
||||
new RegExp(`\\b${numSize}\\s*m?l\\b`, 'i'),
|
||||
new RegExp(`\\b${numSize}m?l\\b`, 'i'),
|
||||
new RegExp(`\\b${numSize}\\s*Tab(let)?s?\\b`, 'i'),
|
||||
];
|
||||
sizeAlreadyInSubtitle = regexList.some((rgx) => rgx.test(subtitle));
|
||||
}
|
||||
|
||||
if (!sizeAlreadyInSubtitle && numSize && numSize > 0) {
|
||||
const sizeStr = unit ? `${numSize} ${unit}` : `${numSize}`;
|
||||
subtitle = `${subtitle} - ${sizeStr}`;
|
||||
}
|
||||
|
||||
@@ -236,7 +248,7 @@ export class TorobController {
|
||||
old_price: oldPrice,
|
||||
availability: isInStock ? "instock" : "outofstock",
|
||||
image_link: imageLink,
|
||||
guarantee: "ضمانت اصالت ۱۰۰٪ کمپانی Canina آلمان و اصالت کالا",
|
||||
guarantee: "ضمانت اصالت ۱۰۰٪ کالای آلمانی، سلامت فیزیکی و تاریخ مصرف بهروز",
|
||||
category_name:
|
||||
product.category?.name ||
|
||||
product.categorySlug ||
|
||||
|
||||
Reference in new issue
Block a user