Import in store

Closed

Import WP Updated 1 year ago 12 Replies

Konstantin asked 1 year ago on February 7, 2023 at 11:48 am

Hello!  I’m importing coupons into a Nike store site, but the name of the store in the import file is Nike WW.  There are many such stores.  What should I do?

J

James replied Support Agent

1 year ago on February 7, 2023 at 12:15 pm

Hi Konstantin,

Can you explain a little more about the issue, what are you wanting to achieve?

You mention a store and coupons, is this an ecommerce plugin?

James

KC

Konstantin Chekhovskoy replied privately

1 year ago on February 7, 2023 at 12:26 pm

J

James replied privately Support Agent

1 year ago on February 7, 2023 at 12:28 pm

KC

Konstantin Chekhovskoy replied

1 year ago on February 7, 2023 at 12:41 pm

your message is empty

J

James replied Support Agent

1 year ago on February 7, 2023 at 12:48 pm

So you are looking to replace the shop name during import to the correct one? This should be possible during the import using a custom method to search and replace the specified text.

An example of how to use custom methods during importing can be found here: https://www.importwp.com/docs/modifying-dates-using-custom-methods/

KC

Konstantin Chekhovskoy replied

1 year ago on February 7, 2023 at 1:08 pm

do not quite understand.  then what code do i need to add to match the store name?

J

James replied Support Agent

1 year ago on February 7, 2023 at 1:17 pm

A very basic example of a custom function to replace "Nike WW" with "Nike Store" would be (add this to your themes functions.php file):

function iwphd_replace_store_name($input = ''){
    $input = str_replace('Nike WW', 'Nike Store', $input);
    return $input;
}

To use this, you would wrap the custom method around the data in the correct template field:

[iwphd_replace_store_name("{0}")]

Replacing {0} with the previously selected csv column or xml node as shown in the attached screenshot where the text "Nike WW Replace test." was replaced with "Nike Store Replace test."

 

KC

Konstantin Chekhovskoy replied

1 year ago on February 7, 2023 at 1:22 pm

thank you friend!  how can i do this if i need to match many store names?

J

James replied Support Agent

1 year ago on February 7, 2023 at 1:35 pm

If you want to replace many stores (Nike WW, Nike ASD) with the same value:

function iwphd_replace_store_name($input = '')
{
    $input = str_replace([
        'Nike WW',
        'Nike ASD',
    ], 'Nike Store', $input);
    return $input;
}

This example would replace:

"Nike WW, Nike ASD, Nike 123"

with:

"Nike Store, Nike Store, Nike 123"

You could easily add more elements to the searching array:

[
    'Nike WW',
    'Nike ASD',
]

e.g.

[
    'Nike WW',
    'Nike ASD',
    'Nike 123',
]

 

 

KC

Konstantin Chekhovskoy replied

1 year ago on February 7, 2023 at 1:40 pm

the fact is that I have a lot of stores that need to be matched by name (example: Apple=AppleWW, ping=pingWW).  I have a lot of store names that don't match.  How to be here?

J

James replied Support Agent

1 year ago on February 7, 2023 at 1:47 pm

Switching to using 2 lists like the following will allow multiple replacements:

function iwphd_replace_store_name($input = '')
{
    // Nike WW -> Nike Store
    // AppleWW -> Apple
    // pingWW -> ping
    $input = str_replace(
        // List of items to be replaced
        [
            'Nike WW',
            'AppleWW',
            'pingWW'
        ],
        // List of replacements
        [
            'Nike Store',
            'Apple',
            'ping'
        ],
        $input
    );
    return $input;
}

Changing:

"Nike WW, AppleWW, pingWW, Test"

To

"Nike Store, Apple, ping, Test"

 

KC

Konstantin Chekhovskoy replied

1 year ago on February 7, 2023 at 1:49 pm

wow thank you!!!!