diff --git a/src/templates/json/JSONTemplate.js b/src/templates/json/JSONTemplate.js index 139bbba..9247a5a 100644 --- a/src/templates/json/JSONTemplate.js +++ b/src/templates/json/JSONTemplate.js @@ -56,7 +56,7 @@ export class JSONTemplate { if (variant) { const offerVariantURLTemplate = matchedPathConfig?.offerVariantURLTemplate; if (!offerVariantURLTemplate) { - return `${productUrl}/?optionsUIDs=${encodeURIComponent(variant.selections.join(','))}`; + return `${productUrl}?optionsUIDs=${encodeURIComponent(variant.selections.join(','))}`; } const variantPath = offerVariantURLTemplate diff --git a/src/templates/json/overrides/wilson-ecommerce--wilson.js b/src/templates/json/overrides/wilson-ecommerce--wilson.js index 7ee397f..a6b7530 100644 --- a/src/templates/json/overrides/wilson-ecommerce--wilson.js +++ b/src/templates/json/overrides/wilson-ecommerce--wilson.js @@ -29,7 +29,8 @@ export default class extends JSONTemplate { * @param {Variant} [variant] */ constructMPN(variant) { - return variant ? variant.sku : this.product.sku; + // only include mpn on product-level + return variant ? undefined : this.product.sku; } renderOffers() { diff --git a/test/fixtures/post-deploy/bella-tank.html b/test/fixtures/post-deploy/bella-tank.html index 28be5c2..4912211 100644 --- a/test/fixtures/post-deploy/bella-tank.html +++ b/test/fixtures/post-deploy/bella-tank.html @@ -46,7 +46,7 @@ { "@type": "Offer", "sku": "WT01-L-Black", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzI%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzI%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-black_main_1.jpg", "availability": "InStock", "price": 29, @@ -55,7 +55,7 @@ { "@type": "Offer", "sku": "WT01-L-Blue", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzI%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzI%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-blue_main_1.jpg", "availability": "InStock", "price": 29, @@ -64,7 +64,7 @@ { "@type": "Offer", "sku": "WT01-L-Orange", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzI%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzI%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-orange_main_1.jpg", "availability": "InStock", "price": 29, @@ -73,7 +73,7 @@ { "@type": "Offer", "sku": "WT01-M-Black", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81Mjk%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81Mjk%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-black_main_1.jpg", "availability": "InStock", "price": 29, @@ -82,7 +82,7 @@ { "@type": "Offer", "sku": "WT01-M-Blue", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81Mjk%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81Mjk%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-blue_main_1.jpg", "availability": "InStock", "price": 29, @@ -91,7 +91,7 @@ { "@type": "Offer", "sku": "WT01-M-Orange", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81Mjk%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81Mjk%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-orange_main_1.jpg", "availability": "InStock", "price": 29, @@ -100,7 +100,7 @@ { "@type": "Offer", "sku": "WT01-S-Black", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjY%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjY%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-black_main_1.jpg", "availability": "InStock", "price": 29, @@ -109,7 +109,7 @@ { "@type": "Offer", "sku": "WT01-S-Blue", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjY%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjY%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-blue_main_1.jpg", "availability": "InStock", "price": 29, @@ -118,7 +118,7 @@ { "@type": "Offer", "sku": "WT01-S-Orange", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjY%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjY%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-orange_main_1.jpg", "availability": "InStock", "price": 29, @@ -127,7 +127,7 @@ { "@type": "Offer", "sku": "WT01-XL-Black", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzU%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzU%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-black_main_1.jpg", "availability": "InStock", "price": 29, @@ -136,7 +136,7 @@ { "@type": "Offer", "sku": "WT01-XL-Blue", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzU%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzU%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-blue_main_1.jpg", "availability": "InStock", "price": 29, @@ -145,7 +145,7 @@ { "@type": "Offer", "sku": "WT01-XL-Orange", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzU%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81MzU%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-orange_main_1.jpg", "availability": "InStock", "price": 29, @@ -154,7 +154,7 @@ { "@type": "Offer", "sku": "WT01-XS-Black", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjM%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzI%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjM%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-black_main_1.jpg", "availability": "InStock", "price": 29, @@ -163,7 +163,7 @@ { "@type": "Offer", "sku": "WT01-XS-Blue", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjM%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xNzU%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjM%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-blue_main_1.jpg", "availability": "InStock", "price": 29, @@ -172,7 +172,7 @@ { "@type": "Offer", "sku": "WT01-XS-Orange", - "url": "https://example.test/products/bella-tank/wt01/?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjM%3D", + "url": "https://example.test/products/bella-tank/wt01?optionsUIDs=Y29uZmlndXJhYmxlLzI3Ny8xOTM%3D%2CY29uZmlndXJhYmxlLzU1Ni81MjM%3D", "image": "https://www.aemshop.net/media/catalog/product/w/t/wt01-orange_main_1.jpg", "availability": "InStock", "price": 29, diff --git a/test/templates/json/JSONTemplate.test.js b/test/templates/json/JSONTemplate.test.js index 5f0c877..7f4a743 100644 --- a/test/templates/json/JSONTemplate.test.js +++ b/test/templates/json/JSONTemplate.test.js @@ -71,7 +71,7 @@ describe('JSONTemplate', () => { // @ts-ignore const url = template.constructProductURL(variant1); - const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ%3D%3D'; + const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ%3D%3D'; assert.strictEqual(url, expectedUrl, 'Variant URL without offerVariantURLTemplate does not match expected URL'); }); @@ -97,7 +97,7 @@ describe('JSONTemplate', () => { // @ts-ignore const url = template.constructProductURL(variantWithSpecialSelections); - const expectedUrl = 'https://www.example.com/products/summer-sun/kw%2055%2F31/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ%3D%3D%2CY29uZmlndXJhYmxlLzI0NjEvMzYzNDE%3D'; + const expectedUrl = 'https://www.example.com/products/summer-sun/kw%2055%2F31?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ%3D%3D%2CY29uZmlndXJhYmxlLzI0NjEvMzYzNDE%3D'; assert.strictEqual(url, expectedUrl, 'Variant URL with special characters does not match expected URL'); }); @@ -114,7 +114,7 @@ describe('JSONTemplate', () => { }), product1, [variantEmptySelections]); // @ts-ignore const url = template.constructProductURL(variantEmptySelections); - const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531/?optionsUIDs='; + const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531?optionsUIDs='; assert.strictEqual(url, expectedUrl, 'URL with empty variant selections does not match expected URL'); });