Created
January 13, 2022 05:22
-
-
Save webtoffee-git/ff95346f26343b141075ca7bc5421f6e to your computer and use it in GitHub Desktop.
Export main image url and additional image urls to separate columns (https://www.webtoffee.com/product/product-import-export-woocommerce/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //do not copy this line | |
add_filter('wt_iew_alter_export_data', 'wt_iew_alter_export_images_separate_column', 10, 6); | |
if(!function_exists('wt_iew_alter_export_images_separate_column')){ | |
function wt_iew_alter_export_images_separate_column($export_data, $offset, $is_last_offset, $file_as, $to_export, $csv_delimiter) { | |
if ($to_export == 'product') { | |
if (isset($export_data['body_data'])) { | |
foreach ($export_data['body_data'] as $key => $value) { | |
if(isset($value['images']) && !empty($value['images'])) { | |
$images = explode('|', $value['images']); | |
foreach ($images as $image_key => $image) { | |
$export_data['body_data'][$key]['image_'.$image_key] = $image; | |
$export_data['head_data']['image_'.$image_key] = 'image_'.$image_key; | |
} | |
unset($export_data['body_data'][$key]['images']); | |
} | |
} | |
} | |
unset($export_data['head_data']['images'] ); | |
} | |
return $export_data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment