foreach($data['variation']['vars'] as $variant) {
$vars = array();
$s = '';
foreach($variant['opt'] as $k_opt => $v_opt) {
$name = base64_decode($k_opt);
$value = $v_opt;
$option = $this->getOption($name);
$opt = $this->getOptionValue($value, $option['id']);
//lookup product option rel table, insert if needed
$product_option_id = $this->getProductOption($product_id, $option['id']);
$product_option_value_id = $this->getProductOptionValue($product_id, $option['id'], $opt['id'], $product_option_id);
$this->openbay->ebay->log('Option data: '.serialize($option));
$s = $option['sort'];
$vars[$s] = $product_option_value_id;
}
//$this->openbay->ebay->log('Unsorted: '.serialize($vars));
//sort the array to the natural sort order
ksort($vars);
//$this->openbay->ebay->log('Sorted: '.serialize($vars));
//remove the key from the array to pass to implode
$vars2 = array();
foreach($vars as $k=>$v)
{
$vars2[] = $v;
}
//implode the values
$vars = implode(':', $vars2);
//$this->openbay->ebay->log('Vars: '.$vars);
//create the variant
$this->createProductVariant(array('var' => $vars, 'price' => $variant['price'], 'stock' => $variant['qty'], 'product_id' => $product_id, 'sku' => $variant['sku']));
}
$this->updateVariantListing($product_id, $data['ItemID']);
//$this->openbay->ebay->log('Item variant stuff done..');