function wpai_woodmart_gallery_image_imported( $post_id, $att_id, $filepath, $is_keep_existing_images = '' ) {
$product = wc_get_product( $post_id );
if ( ! $product ) return;
$variationID_first = get_post_meta( $product->get_id(), wpai_woocommerce_add_on\XmlImportWooCommerceService::FIRST_VARIATION, TRUE );
if ( $product->is_type( 'variation' ) || ! empty( $variationID_first ) ) {
if ( empty( $variationID_first ) ) {
$variationID = $product->get_id();
$parent = $product->get_parent_id();
If you have a slow import, or if you're running into a lot of server timeouts, then you can follow these steps to optimize your import.
Follow all of the steps listed here: http://www.wpallimport.com/documentation/troubleshooting/slow-imports/.
If you provide an image URL that's invalid or that's not available to the server, it can take a while for WP All Import to fail when attempting to download it. To get around this, you can pass your images to a function (see https://www.wpallimport.com/documentation/developers/custom-code/inline-php/) like this:
[my_output_imgs(array({img1[1]},{img2[1]},{img3[1]}))]
Then, use PHP to test them before outputting them in the import template:
This shows how to save a custom log of imported items. It can be adjusted to include any product data.
/***********************************************/
/***** BEGIN LOG CREATE / UPDATE / DELETE *****/
/********************************************* */
// This creates a custom log file in the root WordPress uploads folder
// Some of this code will need to be adjusted, please read comments.
Find attributes by name.
function my_find_attribute_by_name( $name, $attribute ) {
global $wpdb;
$term_table = $wpdb->prefix . 'terms';
$taxonomy_table = $wpdb->prefix . 'term_taxonomy';
if ( ! empty( $name ) ) {
Remove -000x000.ext from image URLs in content by passing the content to a custom PHP function:
[my_fix_images({content[1]})]
Code (save in the Function Editor at All Import › Settings):
function my_fix_img( $img = '' ) {
XPath doesn't allow you to make queries with Cyrillic symbols unless you disable XML pre-processing by adding this code in your child themes functions.php file (or in a plugin like Code Snippets: https://wordpress.org/plugins/code-snippets/):
function wpai_is_xml_preprocess_enabled( $is_enabled ) {
return false;
}
add_filter( 'is_xml_preprocess_enabled', 'wpai_is_xml_preprocess_enabled', 10, 1 );
Once that code is in place, upload your file to an import and queries like this will be possible:
By default, WooCommerce only loads 30 variations on the front-end for variable products. If your product has more variations than that, WooCommerce will not fetch them until they're selected in the drop-downs - which means that unavailable variations will show up in the drop-downs.
If you don't want WooCommerce to display unavailable options in the drop-downs, you'll have to adjust the WooCommerce AJAX Variations Threshold to be more than the amount of variations your product has.
Here's an example snippet that tells WooCommerce to load 100 variations:
function soflyy_change_threshold( $amount, $product ) {
return 100; // change this to the amount of variations you want to load
Use a custom PHP function ( https://www.wpallimport.com/documentation/export/pass-data-through-php-functions/ ) on the content field to convert the image IDs to URLs. Example shortcode:
[vc_single_image image="177" img_size="full" add_caption="yes" alignment="center" style="vc_box_shadow_border"]
Example function:
This function will use the default "jet_rel_default" table in JetEngine to look for the post_id of the parent and return its relations from the "child_object_id" column. If you're using a separate table for your relations, you can change the $table_name value.
- Add a New Field in WP All Export (see https://d.pr/i/OW9dze).
- Set a name for the column and use "ID" for the field to export (see https://d.pr/i/v5Mq98).
- Modify the function as needed, paste it in the Function Editor and paste the name of the function in the "Export the value returned by a PHP function" field (see https://d.pr/i/2c6c07).
- The function will return a list of IDs separated with pipes by default, but if you want to export the titles instead, you need to change the $mode in "function my_export_je_relation ($post_id, $mode = 'id')" to "title".