I'm trying to find some ways to search a vendor-sku inside a product name. I am matching the value of the <vendor-sku>HT900C</vendor-sku>
from retailer's feed inside this <vendor-product-name>Ventilateur TurboForceᴹᴰ HT900C Honeywell</vendor-product-name>
on vendor's feed.
Vendor's Feed:
<?xml version="1.0" encoding="UTF-8"?>
<products module-id="kazfanscafr">
<product type="product" wcpc="1562772927361"><gtin>00092926109004</gtin><vendor-product-name>Ventilateur TurboForceᴹᴰ **HT900C** Honeywell</vendor-product-name><provided-by>Kaz</provided-by>
<product type="product" wcpc="1562774715788"><gtin>00092926310905</gtin><vendor-product-name>Ventilateur Turboᴹᴰ On the GO! HTF090BC Honeywell</vendor-product-name><vendor-clean-product-name>Ventilateur Turboᴹᴰ On the GO **HTF090BC** Honeywell</vendor-clean-product-name><provided-by>Kaz</provided-by>
</products>
Retailer's feed:
<product><vendor>KAZ CANADA INC</vendor><vendor-sku>**HT900C**</vendor-sku><channel-product-name>Fan, High Performance, 8", Black</channel-product-name><channel-product-id>KAZHT900C</channel-product-id><on-sale>true</on-sale><product-url>https://www.eway.ca/Eway/Product/KAZHT900C.aspx</product-url></product>
<product><vendor>KAZ CANADA INC</vendor><vendor-sku>**HTF090BC**</vendor-sku><channel-product-name>Honeywell Turbo on the Go, portable fan</channel-product-name><channel-product-id>KAZHTF090BC</channel-product-id><on-sale>true</on-sale><product-url>https://www.eway.ca/Eway/Product/KAZHTF090BC.aspx</product-url></product>
<product><vendor>KAZ CANADA INC</vendor><vendor-sku>HTF1220C</vendor-sku><channel-product-name>HONEYWELL 12" Portable Table Fan</channel-product-name><channel-product-id>KAZHTF1220C</channel-product-id><on-sale>true</on-sale><product-url>https://www.eway.ca/Eway/Product/KAZHTF1220C.aspx</product-url></product>
<product><vendor>KAZ CANADA INC</vendor><vendor-sku>HTF210BC</vendor-sku><channel-product-name>Quietset table fan</channel-product-name><channel-product-id>KAZHTF210BC</channel-product-id><on-sale>true</on-sale><product-url>https://www.eway.ca/Eway/Product/KAZHTF210BC.aspx</product-url></product>
So my work is basically to find a match between these two feeds, I need to match the vendor's SKU/GTIN to the product's SKU/GTIN posted on retailer's site/feed. I am injecting enriched content to the products, so to do that, I need to match these IDs between the two feeds as a channel or a bridge. But since on this case, I asked help because the SKU was inserted on the product name.
Usually, I can use my default operation to search for their IDs:
<xsl:call-template name="search-feeds-by-sku"> <xsl:with-param name="vendor-data-feed-field-to-compare" select="'gtin'" wcmt:editorDisplay="hidden"/> <xsl:with-param name="product-data-feed-field-to-compare" select="'gtin'" wcmt:editorDisplay="hidden"/> </xsl:call-template>
but on this instance. I need to do a substring or a regex to manipulate the results
I have already tried different substring functions. I couldn't make it work for substring-after and substring-before because of inconsistent format on the product name.
<method confidence="0.9" display-name="map-feed-by-name" xsi:type="map-by-virtual-feed"><product-data-matcher>/products/product[contains(vendor-sku, '{concat('vendor-product-name', " ")}')]</product-data-matcher>
</method>
So I expect to find the vendor-sku (HT900C) inside the product-name since I concatenate by " " (whitespace).
Output should be:
Ventilateur
TurboForceᴹᴰ
HT900C
Honeywell
and by then I should get a match HT900C, but it returns nothing. I'm wondering if I missed something or this whole approach is not recommended at all. I'm using XPath 1.0 and the processor is XSLT 2.0. Thanks for your help in advance!
Here's my current solution
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:import href="eway-fr-ca-fr/map-common.xml" xml:base="{$common-folder-uri}/"/>
<xsl:template match="/"<map-operation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" channel-id="eway-fr-ca-fr" module-id="kazfanscafr">
<skip-if-no-new-channel-product-found ttl-hours="720"/>
<allow-multiple-mappings/>
<methods>
<xsl:call-template name="search-feeds-by-sku"/>
<xsl:call-template name="search-feeds-by-sku">
<xsl:with-param name="vendor-data-feed-field-to-compare" select="'gtin'" wcmt:editorDisplay="hidden"/>
<xsl:with-param name="product-data-feed-field-to-compare" select="'gtin'" wcmt:editorDisplay="hidden"/>
</xsl:call-template>
<method confidence="0.9" display-name="map-feed-by-name" xsi:type="map-by-virtual-feed">
<product-data-matcher>/products/product[contains(vendor-sku, '{concat(vendor-product-name, " ")}')]</product-data-matcher>
</method>
</methods>
</map-operation>
</xsl:template>
</xsl:stylesheet>