2016-05-20 121 views
2

如何使用Magento v2.0 SOAP Web服務獲得產品所屬類別的列表?從Magento v2.0 SOAP API獲取產品類別ID

在​​3210我找到了服務列表。

隨着catalogProductRepositoryV1,我可以要求一個列表或單個產品,但它不包含類別。例如:

請求:

POST http://domain/soap/default?services=catalogProductRepositoryV1 HTTP/1.1 
Content-Type: application/soap+xml; charset=utf-8; action="catalogProductRepositoryV1Get" 
Host: domain 
Content-Length: 382 
Expect: 100-continue 
Accept-Encoding: gzip, deflate 

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <catalogProductRepositoryV1GetRequest xmlns="http://domain/soap/default?services=catalogProductRepositoryV1"> 
      <sku xmlns="">24-MB01</sku> 
     </catalogProductRepositoryV1GetRequest> 
    </s:Body> 
</s:Envelope> 

響應:

HTTP/1.1 200 OK 
Date: Fri, 20 May 2016 12:21:46 GMT 
Server: Apache/2.4.18 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 PHP/5.6.21 
X-Powered-By: PHP/5.6.21 
Set-Cookie: PHPSESSID=89fdd89a6caeb8be424b9531c69d6c69; expires=Fri, 20-May-2016 13:21:47 GMT; Max-Age=3600; path=/; domain=domain; HttpOnly 
Expires: Thu, 19 Nov 1981 08:52:00 GMT 
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 
Pragma: no-cache 
Content-Length: 5547 
X-Content-Type-Options: nosniff 
X-XSS-Protection: 1; mode=block 
Connection: close 
Content-Type: application/soap+xml; charset=utf-8 

<?xml version="1.0" encoding="UTF-8"?> 
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://domain/soap/default?services=catalogProductRepositoryV1"> 
    <env:Body> 
     <ns1:catalogProductRepositoryV1GetResponse> 
      <result> 
       <id>1</id> 
       <sku>24-MB01</sku> 
       <name>Joust Duffle Bag</name> 
       <attributeSetId>15</attributeSetId> 
       <price>34</price> 
       <status>1</status> 
       <visibility>4</visibility> 
       <typeId>simple</typeId> 
       <createdAt>2016-01-22 16:28:25</createdAt> 
       <updatedAt>2016-04-20 09:51:54</updatedAt> 
       <extensionAttributes/> 
       <productLinks> 
        <item> 
         <sku>24-MB01</sku> 
         <linkType>upsell</linkType> 
         <linkedProductSku>24-MB03</linkedProductSku> 
         <linkedProductType>simple</linkedProductType> 
         <position/> 
         <extensionAttributes/> 
        </item> 
        <item> 
         <sku>24-MB01</sku> 
         <linkType>upsell</linkType> 
         <linkedProductSku>24-MB05</linkedProductSku> 
         <linkedProductType>simple</linkedProductType> 
         <position/> 
         <extensionAttributes/> 
        </item> 
        <item> 
         <sku>24-MB01</sku> 
         <linkType>upsell</linkType> 
         <linkedProductSku>24-MB06</linkedProductSku> 
         <linkedProductType>simple</linkedProductType> 
         <position/> 
         <extensionAttributes/> 
        </item> 
        <item> 
         <sku>24-MB01</sku> 
         <linkType>upsell</linkType> 
         <linkedProductSku>24-MB02</linkedProductSku> 
         <linkedProductType>simple</linkedProductType> 
         <position/> 
         <extensionAttributes/> 
        </item> 
        <item> 
         <sku>24-MB01</sku> 
         <linkType>upsell</linkType> 
         <linkedProductSku>24-UB02</linkedProductSku> 
         <linkedProductType>simple</linkedProductType> 
         <position/> 
         <extensionAttributes/> 
        </item> 
        <item> 
         <sku>24-MB01</sku> 
         <linkType>upsell</linkType> 
         <linkedProductSku>24-WB03</linkedProductSku> 
         <linkedProductType>simple</linkedProductType> 
         <position/> 
         <extensionAttributes/> 
        </item> 
        <item> 
         <sku>24-MB01</sku> 
         <linkType>upsell</linkType> 
         <linkedProductSku>24-WB07</linkedProductSku> 
         <linkedProductType>simple</linkedProductType> 
         <position/> 
         <extensionAttributes/> 
        </item> 
        <item> 
         <sku>24-MB01</sku> 
         <linkType>upsell</linkType> 
         <linkedProductSku>24-WB04</linkedProductSku> 
         <linkedProductType>simple</linkedProductType> 
         <position/> 
         <extensionAttributes/> 
        </item> 
       </productLinks> 
       <options/> 
       <mediaGalleryEntries> 
        <item> 
         <id>1</id> 
         <mediaType>image</mediaType> 
         <label>Image</label> 
         <position>1</position> 
         <disabled>false</disabled> 
         <types> 
          <item>image</item> 
          <item>small_image</item> 
          <item>thumbnail</item> 
         </types> 
         <file>/m/b/mb01-blue-0.jpg</file> 
        </item> 
       </mediaGalleryEntries> 
       <tierPrices/> 
       <customAttributes> 
        <item> 
         <attributeCode>description</attributeCode> 
         <value>&lt;p&gt;The sporty Joust Duffle Bag can't be beat - not in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it's ideal for athletes with places to go.&lt;/p&gt;&#13; 
&lt;ul&gt;&#13; 
&lt;li&gt;Dual top handles.&lt;/li&gt;&#13; 
&lt;li&gt;Adjustable shoulder strap.&lt;/li&gt;&#13; 
&lt;li&gt;Full-length zipper.&lt;/li&gt;&#13; 
&lt;li&gt;L 29" x W 13" x H 11".&lt;/li&gt;&#13; 
&lt;/ul&gt;</value> 
        </item> 
        <item> 
         <attributeCode>meta_title</attributeCode> 
         <value>Joust Duffle Bag</value> 
        </item> 
        <item> 
         <attributeCode>meta_keyword</attributeCode> 
         <value>Joust Duffle Bag</value> 
        </item> 
        <item> 
         <attributeCode>meta_description</attributeCode> 
         <value>Joust Duffle Bag &lt;p&gt;The sporty Joust Duffle Bag can't be beat - not in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it's ideal for athletes with places t</value> 
        </item> 
        <item> 
         <attributeCode>image</attributeCode> 
         <value>/m/b/mb01-blue-0.jpg</value> 
        </item> 
        <item> 
         <attributeCode>small_image</attributeCode> 
         <value>/m/b/mb01-blue-0.jpg</value> 
        </item> 
        <item> 
         <attributeCode>thumbnail</attributeCode> 
         <value>/m/b/mb01-blue-0.jpg</value> 
        </item> 
        <item> 
         <attributeCode>category_ids</attributeCode> 
         <value> 
          <xsd:string>3</xsd:string> 
          <xsd:string>4</xsd:string> 
         </value> 
        </item> 
        <item> 
         <attributeCode>options_container</attributeCode> 
         <value>container2</value> 
        </item> 
        <item> 
         <attributeCode>required_options</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>has_options</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>image_label</attributeCode> 
         <value>Image</value> 
        </item> 
        <item> 
         <attributeCode>small_image_label</attributeCode> 
         <value>Image</value> 
        </item> 
        <item> 
         <attributeCode>thumbnail_label</attributeCode> 
         <value>Image</value> 
        </item> 
        <item> 
         <attributeCode>msrp_display_actual_price_type</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>url_key</attributeCode> 
         <value>joust-duffle-bag</value> 
        </item> 
        <item> 
         <attributeCode>tax_class_id</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>activity</attributeCode> 
         <value>11,19,21,22</value> 
        </item> 
        <item> 
         <attributeCode>style_bags</attributeCode> 
         <value>25,26,29</value> 
        </item> 
        <item> 
         <attributeCode>material</attributeCode> 
         <value>37,38</value> 
        </item> 
        <item> 
         <attributeCode>strap_bags</attributeCode> 
         <value>61,62,63,64,65,66</value> 
        </item> 
        <item> 
         <attributeCode>features_bags</attributeCode> 
         <value>74,76,79</value> 
        </item> 
        <item> 
         <attributeCode>eco_collection</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>performance_fabric</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>erin_recommends</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>new</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>sale</attributeCode> 
         <value>0</value> 
        </item> 
        <item> 
         <attributeCode>eboekhouden_grootboekrekening</attributeCode> 
         <value>8000</value> 
        </item> 
        <item> 
         <attributeCode>eboekhouden_costcenter</attributeCode> 
         <value>0</value> 
        </item> 
       </customAttributes> 
      </result> 
     </ns1:catalogProductRepositoryV1GetResponse> 
    </env:Body> 
</env:Envelope> 

回答

4
在產品細節SOAP

呼叫即catalogProductRepositoryV1 你會發現category_ids在customAttributes標籤的物品

<customAttributes> 
... 
<item> 
    <attributeCode>category_ids</attributeCode> 
    <value> 
     <xsd:string>3</xsd:string> 
     <xsd:string>4</xsd:string> 
    </value> 
</item> 
... 
</customAttributes> 

比你需要加載類別,如果你想要一個ny的信息從目錄categoryRepositoryV1

+0

所以,它一直在響應..嘆氣。我現在明白了爲什麼我以前沒有看到它。如果使用'catalogProductRepositoryV1GetListRequest',則不會在List Api中獲得customAttribute category_ids .. –

+0

只有默認值,category_ids在Product detail API中 –