Home › Forums › WoodMart support forum › I am having trouble importing variation images
I am having trouble importing variation images
- This topic has 3 replies, 2 voices, and was last updated 11 months ago by Artem Temos.
-
AuthorPosts
-
May 30, 2023 at 8:55 pm #471256
AlexParticipantI am unable to import variations images, I have tried both “Parent product meta” and “Variations products meta” for the data storage method, I am using WP all import.
Can you help me out?
I have also contacted WP all import support in parallel since it is a bit of both.
Attachments:
You must be logged in to view attached files.May 31, 2023 at 9:25 am #471311
Artem TemosKeymasterHello,
You need to select the “Variations products meta” variant. Variations images ids are stored as meta for each variation post in the database. So you need to format your import file properly. Please, refer to the plugin’s documentation or contacts its developers for help on this matter.
Kind Regards
June 14, 2023 at 1:45 pm #474869
AlexParticipantSelect the variations products meta and then paste this code into the custom function field for anyone who has the same issue:
// WoodMart variation gallery
function gallery_ids_in_string($post_id, $att_id, $filepath, $is_keep_existing_images = ”){
// The custom field used by gallery.
$key = ‘wd_additional_variation_images_data’;// The separator to use between each ID.
$separator = “,”;// Retrieve the current values in the gallery field.
$gallery = get_post_meta($post_id, $key, true);// Ensure gallery is valid.
if (is_string($gallery) || is_empty($gallery) || ($gallery == false)) {// Split value into array.
$gallery = explode($separator, $gallery);// Add image if it’s not in the gallery.
if (!in_array($att_id, $gallery)) {// Ensure array doesn’t start with empty value.
if ($gallery[0] == ”) unset($gallery[0]);// Add image ID to array.
$gallery[] = $att_id;// Save updated gallery field.
update_post_meta($post_id, $key, implode($separator, $gallery));}
}
}add_action(‘pmxi_gallery_image’, ‘gallery_ids_in_string’, 10, 4);
// Remove first image from gallery
function import_remove_featured_image_from_gallery($post_id, $xml_node) {
$thumbnail = get_post_meta($post_id, “_thumbnail_id”, true);
$gallery = get_post_meta($post_id, “wd_additional_variation_images_data”, true);
$gallery_array = explode(“,”, $gallery);$check_thumbnail = array_search($thumbnail,$gallery_array);
if( $check_thumbnail !== false ) {
unset($gallery_array[$check_thumbnail]);
}$gallery = implode(“,”, $gallery_array);
update_post_meta($post_id, “wd_additional_variation_images_data”, $gallery);
}add_action(‘pmxi_saved_post’, ‘import_remove_featured_image_from_gallery’, 10, 2);
June 15, 2023 at 9:06 am #475049
Artem TemosKeymasterThank you very much for posting your solution here. It will be useful for other WoodMart users.
Kind Regards
-
AuthorPosts
Tagged: variation images
The topic ‘I am having trouble importing variation images’ is closed to new replies.
- You must be logged in to create new topics. Login / Register