@jpowersdev you can see the issue in the second JSON on the <img /> tag for example, they are missing the \ character.
Hi @danidub,
It looks like it’s not escaping the HTML correctly. As you said, each ” needs to have a \ before it, and not all of them do.
I’m not really sure why that would be the case. You can look at the wordpress escaping functions (wp_slash, wp_unslash, esc_js, wp_json_encode, etc.), or check what WooCommerce is doing when reading in the csv file. wp_json_encode should escape all quotes in the string, and json_decode should unescape them when converting to an array.
Let me know what you find,
Jon
Hey @jpowersdev,
I have solved the issue reading the meta field from the product object instead of the $data object.
This is the only function I have on the new website for importing the data.
And you need to select the custom meta from the CSV as custom meta so you can get the value on the product $object
function process_import($object, $data)
{
if ($object->meta_exists( 'yikes_woo_products_tabs' )) {
//error_log(print_r($data, true));
$product_meta_field = $object->get_meta('yikes_woo_products_tabs');
$arr = json_decode($product_meta_field, true);
$object->update_meta_data('yikes_woo_products_tabs', $arr);
}
return $object;
}
add_filter('woocommerce_product_import_pre_insert_product_object', 'process_import', 10, 2);
-
This reply was modified 4 years, 5 months ago by
Daniel P..
Hi @danidub,
Interesting, okay. I wonder if that’s been changed in the last few months since the article was written. I’ll revisit that.
Thanks for coming back and letting us know your solution. Were you able to perform a successful import? Are the tabs showing up on the new site?
Jon
Hello @jpowersdev,
Yes, all tabs are restored on product imports. All is working as it should. But remember, only using the function above and selecting the meta field as “import as meta”.
Maybe you need to test again your article.
Thank you for your help and time. Marking this as resolved.
Hi @danidub,
Great, glad you got it working! Let us know if you need anything in the future.
Thanks,
Jon