public function prepareVariations($post_id, $profile, $post, $data)
 {
     global $wpdb;
     // get variations
     $variations = WPLA_ProductWrapper::getVariations($post_id);
     // process variations (childs)
     foreach ($variations as $var) {
         // get variation product data
         $variation_id = $var['post_id'];
         $variation_attributes = $var['variation_attributes'];
         $variable_product = get_product($variation_id);
         if (!$variable_product) {
             continue;
         }
         // echo "<pre>";print_r($var);echo"</pre>";#die();
         // skip hidden variations
         if (get_post_meta($variation_id, '_amazon_is_disabled', true) == 'on') {
             continue;
         }
         // compile variation-theme from attribute names
         $attribute_names = array_keys($variation_attributes);
         // foreach ($attribute_names as &$name) {
         // 	$name = WPLA_FeedDataBuilder::convertToEnglishAttributeLabel( $name );
         // }
         $vtheme = join('-', $attribute_names);
         // generate title suffix from attribute values
         $attribute_values = array_values($variation_attributes);
         $suffix = join(', ', $attribute_values);
         // handle custom listing title
         $listing_title = $post->post_title;
         if ($product_value = get_post_meta($post_id, '_amazon_title', true)) {
             $listing_title = $product_value;
         }
         // build single variation listing item
         $data = array();
         $data['post_id'] = $variation_id;
         $data['parent_id'] = $post_id;
         $data['vtheme'] = $vtheme;
         $data['listing_title'] = $listing_title . ', ' . $suffix;
         // $data['post_content']  = $post->post_content;
         $data['price'] = WPLA_ProductWrapper::getPrice($variation_id);
         $data['quantity'] = WPLA_ProductWrapper::getStock($variation_id);
         $data['sku'] = WPLA_ProductWrapper::getSKU($variation_id);
         $data['date_created'] = date('Y-m-d H:i:s', time());
         $data['status'] = 'prepared';
         $data['source'] = 'woo';
         $data['profile_id'] = $profile->profile_id;
         $data['account_id'] = $profile->account_id;
         $data['product_type'] = $variable_product->product_type;
         WPLA()->logger->info('insert new variation ' . $variation_id . ' - title: ' . $data['listing_title']);
         WPLA()->logger->debug(print_r($post, 1));
         // insert in listings table
         $wpdb->insert($this->tablename, $data);
         echo $wpdb->last_error;
         // apply profile (price)
         $listing_id = $wpdb->insert_id;
         $this->applyProfileToItem($profile, $listing_id);
     }
     // return $wpdb->insert_id;
     return $data;
 }
 function column_sku($item)
 {
     $item_sku = $item['sku'];
     $prod_sku = WPLA_ProductWrapper::getSKU($item['post_id']);
     $sku = $item_sku;
     // check for missing SKU
     if (!$item_sku && !$prod_sku) {
         $sku = 'No SKU';
         $sku = '<span style="color:darkred">' . $sku . '</span>';
     }
     // check if SKU in WooCommerce and WP-Lister are the same
     if ($item_sku !== $prod_sku && $item['status'] != 'imported' && !empty($prod_sku)) {
         $tip_msg = 'The SKU for this item is different in WooCommerce. You need to make sure the SKU is the same as on Amazon or feed processing will fail.';
         $img_url = WPLA_URL . '/img/error.gif';
         $tip_msg = '&nbsp;<img src="' . $img_url . '" style="height:12px; padding:0;" class="tips" data-tip="' . $tip_msg . '"/>&nbsp;';
         $sku = 'Warning' . $tip_msg;
         $sku .= '<br>' . $item_sku;
         $sku .= '<br>' . $prod_sku;
         $sku .= '<br>SKU mismatch!';
         $sku = '<span style="color:darkred">' . $sku . '</span>';
     }
     // check if SKU in WooCommerce is empty
     if ($item_sku !== $prod_sku && $item['status'] != 'imported' && empty($prod_sku)) {
         $tip_msg = 'The SKU for this product is empty in WooCommerce.<br><br> You need to make sure each product and each variation has a unique SKU. This SKU needs to be same as on Amazon or feed processing will fail.';
         $img_url = WPLA_URL . '/img/error.gif';
         $tip_msg = '&nbsp;<img src="' . $img_url . '" style="height:12px; padding:0;" class="tips" data-tip="' . $tip_msg . '"/>&nbsp;';
         $sku = 'No SKU' . $tip_msg;
         $sku .= '<br>' . $item_sku;
         // show warning if WooCommerce product has been deleted
         if (!$this->getProduct($item['post_id']) && $item['status'] != 'imported') {
             $sku = 'No Product!';
         }
         $sku = '<span style="color:darkred">' . $sku . '</span>';
     }
     // if item has variations count them...
     if ($item['post_id'] && WPLA_ProductWrapper::hasVariations($item['post_id'])) {
         $variations = $this->getProductVariations($item['post_id']);
         foreach ($variations as $var) {
             if (!$var['sku']) {
                 $sku = '<br><span style="color:darkred">' . 'Missing variable SKUs' . '</span>';
             }
         }
     }
     //Return the title contents
     return sprintf('%1$s<br><span style="color:silver">%2$s</span>', $sku, $item['asin']);
 }