新接口中,商品更新接口采用增量更新模式,和旧接口中的update.field类似,即传入哪些字段,就只会更新哪些字段。以下列举一些常用的部分更新场景的使用样例(部分字段之间有联动,例如价格类型是规格价时,SKU里必须填写SKU价,类似联动请参见商品发布文档。)。
<itemSchema> <field id="productTitle" name="Product name" type="input"> <value>wang chen test api submit sourcing updateFields 333</value> </field> </itemSchema>
注意当前商品接口只支持普通编辑,修改详情时,需要带上详情类型字段 productDescType ,同时需要确保提交上来的详情里的html标记,都是转义后的。
<field id="productDescType" name="Product Detail" type="singleCheck"> <value>2</value> </field> <field id="superText" name="Custom Description " type="input"> <value><p>test</p></value> </field>
价格类型变化时,需要在对应的价格类型字段中,标识出当前的价格类型,即scPrice ,然后再将具体的价格数据上传,例如fob字段。同时需要注意的是,当价格类型改变时,某些组件是否必填也会发生变化,例如本例子中,阶梯价变成FOB价时,商品的最小起订量就必须单独传递进来,放在minOrderQuantity字段中。更多这种字段联动的情况,可参考 【新接口】商品发布使用文档中的字段说明。
<itemSchema> <field id="minOrderQuantity" name="MOQ" type="input"> <value>3.11</value> </field> <field id="scPrice" name="Price Setting" type="singleCheck"> <options> <option displayName="Set uniform price of FOB" value="1"/> <option displayName="Set one FOB price" value="2"/> </options> <value>2</value> </field> <field id="fob" name="FOB Price" type="complex"> <complex-value> <field id="range_min" type="input"> <value>12.34</value> </field> <field id="range_max" type="input"> <value>56.78</value> </field> <field id="unit_type" type="singleCheck"> <value>4</value> </field> </complex-value> </field> </itemSchema>
<itemSchema> <field id="scPrice" name="Price Setting" type="singleCheck"> <options> <option displayName="Set uniform price of FOB" value="1"/> <option displayName="Set one FOB price" value="2"/> </options> <value>1</value> </field> <field id="ladderPrice" name="Quantity Price" type="complex"> <complex-value> <field id="ladderPrice_1" type="complex"> <complex-value> <field id="quantity" type="input"> <value>3333</value> </field> <field id="price" type="input"> <value>233.0000</value> </field> </complex-value> </field> <field id="ladderPrice_0" type="complex"> <complex-value> <field id="quantity" type="input"> <value>22</value> </field> <field id="price" type="input"> <value>3333.0000</value> </field> </complex-value> </field> </complex-value> </field> </itemSchema>
下面的demo,需要变更前的商品有销售属性和SKU,即saleProp和sku两个字段都有值。如果没有的话,则必须添加销售属性和SKU才能完成变更。
如果商家想变更销售属性,不能只变更saleProp字段,必须同时变更SKU字段,保持两个字段的销售属性是一致的,系统才能保存新增的变化。
<itemSchema> <field id="marketPrice" name="Price Setting " type="singleCheck"> <value>2</value> </field> <field id="saleProp" name="Sales Property" type="complex"> <complex-value> <field id="p-191286172" name="Size" type="multiCheck"> <values> <value inputValue="one size">4348586</value> <value inputValue="XXL">28318</value> </values> </field> <field id="p-191288010" name="Color" type="multiCheck"> <values> <value inputValue="BROWN">3399503</value> </values> </field> </complex-value> </field> <field id="sku" name="" type="multiComplex"> <complex-values> <field id="price" name="Price" type="input"> <value>23.00</value> </field> <field id="skuStock" name="Quantity in stock" type="multiInput"> <values> <value srcValue="4" warehouseCode="CN_LOCAL_01">44</value> </values> </field> <field id="skuOuterId" name="sku code" type="input"> <value>sku2</value> </field> <field id="skuId" name="" type="input"> </field> <field id="props" name="" type="multiInput"> <values> <value propValueId="28318" propId="191286172" propName="p-191286172" propValueName="XXL">111:333;22,11</value> <value propValueId="3399503" propId="191288010" propName="p-191288010" propValueName="Brown">111:333;22,11</value> </values> </field> </complex-values> <complex-values> <field id="price" name="Price" type="input"> <value>23.00</value> </field> <field id="skuStock" name="Quantity in stock" type="multiInput"> <values> <value srcValue="3" warehouseCode="CN_LOCAL_01">33</value> </values> </field> <field id="skuOuterId" name="sku code" type="input"> <value>sku1</value> </field> <field id="skuId" name="" type="input"> </field> <field id="props" name="" type="multiInput"> <values> <value propValueId="4348586" propId="191286172" propName="p-191286172" propValueName="Free">111:333;22,11</value> <value propValueId="3399503" propId="191288010" propName="p-191288010" propValueName="Brown">111:333;22,11</value> </values> </field> </complex-values> </field> </itemSchema>