You are here:  » Only Add Certain Products with Drop if Not RegExp

Active Forum Topics


Only Add Certain Products with Drop if Not RegExp

Submitted by TWDesigns on Thu, 2017-10-12 03:36 in

Hey David,

For what every reason I am at a lose tonight so I have a couple questions.

1.) I am wanting to import only Bras from feeds. I tried to drop products if they do not contain the word bra /(bra)/i/ which works but it includes products such as bracelets which I do not want. Since I am looking for both Bra and Bras I keep running in to issues. How do I force it to only import the word BRA and not a variation of it?

2.) Niche Mode: Is there any good topics on this so that I can understand it better. Is it only for Product mapping? It seems like this is something I need to use but if I map a product as in the example above I get the same issues.

Submitted by support on Thu, 2017-10-12 08:46

Hi,

You can use the \b (word boundary) flag in the regexp to ensure that only whole words match - have a go with:

/\bbra\b/i

Niche mode is connected to Product Mapping - when enabled only products which are configured in Product Mapping are imported. Bear in mind that you don't need to have any Alternatives entered on the configuration page for a mapping - if you create a new mapping with a product name exactly matching an existing merchant product name because you want it to be imported that is all you need to do...

Bear in mind that once enabled the admin search tools will only have visibility of the imported product set - however it is a straight forward modification to create a second "products_all" table to which all products are imported, and can then be used to work on further mappings in /admin/ whilst the front-end is still restricted to the products already configured in Product Mapping. If that would be convenient, if you could email me includes/admin.php and admin/helper.php i'll apply that for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by TWDesigns on Thu, 2017-10-12 14:49

So I should probably be using something like /(\b(Bra)\b|\b(Bras)\b)/i in order to get both singular and plural forms? Also in the example you give for /\b(\d+(LB|UB|EA)\w+)\b/U what does the /U doing at the end? THanks!

Submitted by support on Thu, 2017-10-12 16:18

Hi,

Using both singular and plural options bracketed and separated by the pipe character will work fine, alternatively, you could bracket the "s" and make it optional using the * (zero or more) postfix e.g.

/\bbra(s*)\b/i

The U modifier in the examples means un-greedy and will match the shortest string possible. By default, a regular expression parser will try to match the longest string possible for an expression...

Cheers,
David.
--
PriceTapestry.com