Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter rootcase

    (@rootcase)

    Hi,

    This solution needs some manual work by replacing the strings in the database.
    I’ve placed comments in above code example as hints where to place the function. Part of it goes in your theme’s functions.php and the other part goes on any excutable php file, I used the header.php.

    You need to access the meta_keys _cpo_content from the table postmeta in your database. Paste those strings in the header.php part of the code, run the website, copy the encoded result back to the database.

    So be sure to replace the OLDURL, NEWURL and ENCODED_STRING_FROM_CPO_CONTENT in my code example.

    If you need any more pointers feel free to reply or message me.

    Thread Starter rootcase

    (@rootcase)

    For anyone stumbling across this post:

    The reply to my email stated the official supported way is to go trough all suboptions and reselect the image on the new URL. Since this was no option for me I have digged further and came up with the following.

    I found the complete product data stored in the table postmeta with meta_keys _cpo_content. These strings are encoded by a uni cpo function.
    That explains why the urls remained in the database and weren’t replaced, they were encoded.

    I have wrote the following for my products, since I had 28 products I replaced the encoded strings manually in the database. You could make a function pulling all _cpo_content columns, decode, str_replace, encode and update db.

    
    <?php
    // function in functions.php
    
    function replacer(& $item, $key)
    {
        $item = str_replace(“OLDURL", “NEWURL", $item);
    }
    
    // I placed the following just below the opening body tag
    
    $originalString =‘ENCODED_STRING_FROM_CPO_CONTENT'; //copy from _cpo_content in database
    $decodedString = uni_cpo_decode($originalString);
    array_walk_recursive($decodedString, 'replacer');
    echo uni_cpo_encode($decodedString); //paste back to db. 
    die();
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)