Plugin Directory

Changeset 357452

Timestamp:
03/08/2011 10:34:24 PM (13 years ago)
Author:
jghazally
Message:

Fix convert products to posts so that sku works~ added new functino old_get_product_meta

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-e-commerce/branches/3.8-development/wpsc-admin/includes/updating-functions.php

    r357431 r357452  
    162162        $post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product['id'] ));
    163163       
    164         $sku = get_product_meta($product['id'], 'sku', true);
     164        $sku = get_product_meta($product['id'], 'sku', true);
    165165
    166166        if($post_id == 0) {
     
    589589    }   
    590590}
    591 
     591/*
     592 * The Old Get Product Meta for 3.7 Tables used in converting Products to Posts
     593 */
     594
     595function old_get_product_meta($product_id, $key, $single = false) {
     596  global $wpdb, $post_meta_cache, $blog_id; 
     597  $product_id = (int)$product_id;
     598  if($product_id > 0) {
     599    $meta_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN('$key') AND `product_id` = '$product_id' LIMIT 1");
     600    //exit($meta_id);
     601    if(is_numeric($meta_id) && ($meta_id > 0)) {     
     602      if($single != false) {
     603        $meta_values = maybe_unserialize($wpdb->get_var("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN('$key') AND `product_id` = '$product_id' LIMIT 1"));
     604            } else {
     605        $meta_values = $wpdb->get_col("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN('$key') AND `product_id` = '$product_id'");
     606                $meta_values = array_map('maybe_unserialize', $meta_values);
     607            }
     608        }
     609    } else {
     610    $meta_values = false;
     611    }
     612    if (is_array($meta_values) && (count($meta_values) == 1)) {
     613        return array_pop($meta_values);
     614    } else {
     615        return $meta_values;
     616    }
     617}
    592618?>
Note: See TracChangeset for help on using the changeset viewer.