1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
来自www.hellokeykey.com
$product_name, 'websites' => $product_website, 'short_description' => $product_sdes, 'description' => $product_des, 'price' => $product_price, 'status' => $product_status, 'weight' => $product_weight, 'news_from_date' => $product_news_from_date, 'news_to_date' => $product_news_to_date, 'tax_class_id' => $product_tax_class_id, 'visibility' => $product_visibility, 'url_key' => $product_name, 'cost' => $product_cost, 'special_price' => $product_special_price, 'special_from_date' => $product_special_from_date, 'special_to_date' => $product_special_to_date, 'enable_googlecheckout' => $product_enable_googlecheckout, 'custom_design' => $product_custom_design, 'custom_layout_update' => $product_custom_layout_update, 'page_layout' => $product_page_layout, 'custom_design_from' => $product_custom_design_from, 'custom_design_to' => $product_custom_design_to, 'gift_message_available' => $product_gift_message_available, ); // 产品图片 // 初始化产品图片信息,注意自己上传个产品图片到magento的产品图片文件夹 // label为图片的alt属性 // position 为图片的显示顺序 // type 为此图片作为'thumbnail','small_image','image'中的哪一个 // mime为图片类型
$newImage = array( 'file' => array( 'name' => 'file_name', 'content' => base64_encode(file_get_contents($imagePath)), 'mime' => 'image/jpeg' ), 'label' => 'Cool Image Through Soap', 'position' => 1, 'types' => array('thumbnail', 'small_image', 'image'), 'exclude' => 0 ); // array( // 'file' => array( // 'name' => 'file_name', // 'content' => base64_encode(file_get_contents('/media/catalog/product/m/o/model.jpg')), // 'mime' => 'image/jpeg' // ), // 'label' => 'Cool Image Through Soap', // 'position' => 2, // 'types' => array('small_image'), // 'exclude' => 0 // ) // print_r($newImage); echo 'New product Info: '; echo "New product NO.:" . $client->call($session, 'product.create', array($product_type, $attribute_set, $product_sku, $newProductData)); echo " "; // 使用api创建一个商品(本代码来自www.hellokeykey.com) $see_new_product_info = $client->call($session, 'product.info', $product_sku); // 更新商品的库存信息 $client->call($session, 'product_stock.update', array($product_sku, array('manage_stock' => $product_manage_stock, 'qty' => $product_qty, 'is_in_stock' => "1"))); // 设置商品分类 $client->call($session, 'category.assignProduct', array($product_category_id, $product_sku, 1)); // 创建产品图片,注意是先有产品后添加图片的 $imageFilename = $client->call($session, 'product_media.create', array($product_sku, $newImage)); //输出刚创建的产品信息 $see_new_product_info = $client->call($session, 'product.info', $product_sku); var_dump($see_new_product_info); echo "stock:"; // 输出库存信息 var_dump($client->call($session, 'product_stock.list', $product_sku)); echo "
"; echo 'New Product Image info: '; var_dump($client->call($session, 'product_media.list', $product_sku)); // $attributeSets = $attributeSets[1]; // $attributeSet_ID = array_search('Default',$attributeSets); // echo " "; // echo "Default AttributeSet ID;".$attributeSet_ID; // $set = current($attributeSets); // 以下为示例输出,一个是输出现有的属性组以及代码。然后是输出一个magento simple product产品,自己后台新建一个产品,将此产品的属性填写完整,好输出来分析下各个属性值的特点,与自己要创建的坐下对比 $attributeSets = $client->call($session, 'product_attribute_set.list'); $attributes = $client->call($session, 'product_attribute.list','40'); $attribute_options = $client->call($session, 'product_attribute.options', array('attribute_id'=>'502')); // $set = current($attributeSets); // $attributes = $client->call($session, 'product_attribute.list', $set['set_id']); // var_dump($attributes); echo 'Attribute Sets: '; var_dump($attributeSets); echo 'Attribute Set of shoes: '; var_dump($attributes); echo 'Attribute shoes_size: '; var_dump($attribute_options); echo 'Product Date: '; // echo " set "; // var_dump($set); $sku_of_product = "HTC Touch Diamond"; $p_info = $client->call($session, 'product.info', $sku_of_product); var_dump($p_info); echo "stock:"; var_dump($client->call($session, 'product_stock.list', $sku_of_product)); echo "
"; echo " "; echo 'Product Image info: '; var_dump($client->call($session, 'product_media.list', $sku_of_product)); // $attribute_options = $client->call($session, 'product_attribute.options', array('attribute_id'=>'put_attribute_id_as_int_here')); //var_dump($attribute_options); ?>
|