diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-08-15 07:22:06 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-08-15 07:22:06 +0000 |
| commit | 492e4a875ec7259be80bb4b501bc62e7afa0c9c7 (patch) | |
| tree | d711f0109795b9a49bc5c30f986e9ee429a2171e /src/lib | |
| parent | 9d16a4a7f15ce7fe89ff1d451f567064d5030c2f (diff) | |
| parent | 4fb570559e293d506819059ce42836562a2fb4d2 (diff) | |
Merged in Feature/template-switch (pull request #240)
<iman> update search product using name
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktopVariant.jsx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index b8ec0580..c8a5a205 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -137,20 +137,25 @@ const ProductDesktopVariant = ({ }); } }; + const regex = /\b(?![A-Z\s]+\b)[A-Za-z\s]+\b/g; + const matches = product?.parent?.name?.match(regex); + const extractedName = matches ? matches.join(' ').trim() : ''; + console.log("extractedName",extractedName) const productSimilarQuery = [ product?.name, `fq=-product_id_i:${product.id}`, `fq=-manufacture_id_i:${product.manufacture?.id || 0}`, ].join('&'); - + const [productSimilarInBrand, setProductSimilarInBrand] = useState(null); - + useEffect(() => { const loadProductSimilarInBrand = async () => { const productSimilarQuery = [ product?.name, `fq=-product_id_i:${product.id}`, + `fq=display_name_s:${extractedName}`, ].join('&'); const dataProductSimilar = await productSimilarApi({ query: productSimilarQuery, |
