在Magento SOAP API XML中设置属性选项



使用 SOAP Magento API 1.9 一次只能设置一个属性选项吗?我尝试使用以下XML设置多个选项,但没有成功。谁能帮忙?

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:catalogProductAttributeAddOption soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <sessionId xsi:type="xsd:string">8e72f087a574773ba0dc017e8268d268</sessionId>
         <attribute xsi:type="xsd:string">215</attribute>
         <data xsi:type="urn:catalogProductAttributeOptionEntityToAdd">
            <!--You may enter the following 3 items in any order-->
            <label soapenc:arrayType="urn:catalogProductAttributeOptionLabelEntity[3]" xsi:type="urn:catalogProductAttributeOptionLabelArray">
            <item xsi:type="ns1:catalogProductAttributeOptionLabelEntity">
                  <store_id xsi:type="xsd:string">0</store_id>
                  <value xsi:type="xsd:string">steel6</value>
               </item>
                <item xsi:type="ns1:catalogProductAttributeOptionLabelEntity">
                  <store_id xsi:type="xsd:string">0</store_id>
                  <value xsi:type="xsd:string">steel1</value>
               </item>
                <item xsi:type="ns1:catalogProductAttributeOptionLabelEntity">
                  <store_id xsi:type="xsd:string">0</store_id>
                  <value xsi:type="xsd:string">steel2</value>
               </item>
            </label>
            <order xsi:type="xsd:int">0</order>
            <is_default xsi:type="xsd:int">0</is_default>
         </data>
      </urn:catalogProductAttributeAddOption>
   </soapenv:Body>
</soapenv:Envelope>

我终于找到了上述问题的答案,Magento API "catalogProductAttributeAddOption"一次只用于设置一个选项,但是API可以扩展为设置多个选项。

所以要设置选项的 API 将是

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:catalogProductAttributeAddOption soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <sessionId xsi:type="xsd:string">8e72f087a574773ba0dc017e8268d268</sessionId>
         <attribute xsi:type="xsd:string">215</attribute>
         <data xsi:type="urn:catalogProductAttributeOptionEntityToAdd">
            <!--You may enter the following 3 items in any order-->
            <label soapenc:arrayType="urn:catalogProductAttributeOptionLabelEntity[1]" xsi:type="urn:catalogProductAttributeOptionLabelArray">
            <item xsi:type="ns1:catalogProductAttributeOptionLabelEntity">
                  <store_id xsi:type="xsd:string">0</store_id>
                  <value xsi:type="xsd:string">steel1</value>
               </item>
            </label>
            <order xsi:type="xsd:int">0</order>
            <is_default xsi:type="xsd:int">0</is_default>
         </data>
      </urn:catalogProductAttributeAddOption>
   </soapenv:Body>
</soapenv:Envelope>

最新更新