How to replace any string from the feed?

You can replace any string in your feed using the CTX Feed Plugin. This advantage is only accessible in our Premium Plugin. Using the advanced Command, it’s possible to replace any string from the feed.

You may want to replace any word with your own word when it exists in an attribute value. Suppose, in some products, your product’s titles contain a word called Small, but you want your feed to be generated with S instead of Small also, you don’t want to change your original product title on the Site. So, how will you do it? We are going to cover the solution here. 

CTX Feed Free

There are two options to replace any string from feed.

Option 1:

It is pretty simple. Let’s start…

  1. At first, In the feed edit page, click on the “Filter” tab.

    CTX feed filter tab

In the Filter tab, you will find an option String Replace. Select an attribute, give a search value and replace the value. You can also add multiple strings replace by click on the “Add New Row” button. Then click on the Update and Generate feed button. You should find the replaced value in the attributes.

How to replace any string from feed

Option 2:

To replace any string use the command [ str_replace => from => to]. Change from and to with your desired string. Copy the command and paste it into the command field of your attribute.

Learn more about the commands and their applications from here: How to use a command to format attribute output?

Example 1:  If you want to replace your category separator from >” to “|” your command will be [str_replace => > => | ] .

Example 2:  If you want to replace “,” with “>” then your command will be [str_replace =>comma=>>].

Example 3: Let’s say, you want to replace ABC with XYZ. Then the command will be: [str_replace => ABC => XYZ]

Note* There is also preg_replace command to replace any string but only developers are recommended to use this command. For example, if you want to replace empty space “ ” with underscore “-” then the command will be [preg_replace /\s+/ -]

CTX Feed Free
2 thoughts
  1. Hi,

    we have product categories that contain [shy] in the category name which outputs as ­ in the frontend and in the xml feed.
    This ­ needs to be removed from the feed output, but no matter what I try, it’s still there!

    Output example:

    subcategory ]]>

    Please provide help how I can solve this!

    Thanks
    Stefanie

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.