Deploy on-change script to multiple cat items

SMITS
Tera Contributor

Our client has asked us to script the phone number field in all cat items to have specific formatting. There are roughly 200 cat items that have the phone variable in it, and we have a script that does what they want. We were hoping to leverage Regex but learned that regex can't call scripts and are now looking for a way to deploy this to all cat items without having to touch each one. Anyone have any thoughts on this? Thanks all

1 REPLY 1

jcmings
Mega Sage

One option, which may be painful because it'll require you to touch each one, would be to move the phone variable into a variable set, and then include the client script in the variable set, and add that to each catalog item. You could probably script this so that you (1) capture the metadata of the phone variable (e.g. its order, name, etc), (2) insert the variable set at the same order, and (3) remove the variable. This is probably the more sustainable version; in the event that changes need to be made to the formatting in the future, you only have to make the change in one place.

 

My other approach also involves scripting (likely a fix script). You'll need identify every catalog item that contains the variable (via the item_option_new table), and then use a loop to create the catalog client script on each of those cat items.