2010-12-08 107 views
2

所以,我有一個產品具有自定義選項。在這種情況下,它的顏色。現在我要從一個大的xml文件導入所有商店產品列表,所以我選擇使用自定義選項而不是屬性。現在,我正在使用magento api webservice中的大部分功能。Magento WSDL和產品

所以我有以下幾點。

$products = $api->soap()->call($api->session(), 'catalog_product.list'); 
foreach($products as $product) 
{ 
    print_r($product); 
    echo "<br />"; 

} 

現在我可以從'has_options'字段中看到什麼產品具有自定義選項。但是,如何查看自定義選項? 'options_container'字段的值爲「container2」,我想怎麼做呢?

此外,使用Magento的API創建Web服務產品時.....

$api->soap()->call($api->session(), 'catalog_product.create', product_array_values); 

如何產生的產品的定製選項?

回答

2

這是不可能的,因爲在WSDL我們沒有描述product_option

<complexType name="catalogProductCreateEntity"> 
     <all> 
      <element name="categories" type="typens:ArrayOfString" minOccurs="0" /> 
      <element name="websites" type="typens:ArrayOfString" minOccurs="0" /> 
      <element name="name" type="xsd:string" minOccurs="0" /> 
      <element name="description" type="xsd:string" minOccurs="0" /> 
      <element name="short_description" type="xsd:string" minOccurs="0" /> 
      <element name="weight" type="xsd:string" minOccurs="0" /> 
      <element name="status" type="xsd:string" minOccurs="0" /> 
      <element name="url_key" type="xsd:string" minOccurs="0" /> 
      <element name="url_path" type="xsd:string" minOccurs="0" /> 
      <element name="visibility" type="xsd:string" minOccurs="0" /> 
      <element name="category_ids" type="typens:ArrayOfString" minOccurs="0" /> 
      <element name="website_ids" type="typens:ArrayOfString" minOccurs="0" /> 
      <element name="has_options" type="xsd:string" minOccurs="0" /> 
      <element name="gift_message_available" type="xsd:string" minOccurs="0" /> 
      <element name="price" type="xsd:string" minOccurs="0" /> 
      <element name="special_price" type="xsd:string" minOccurs="0" /> 
      <element name="special_from_date" type="xsd:string" minOccurs="0" /> 
      <element name="special_to_date" type="xsd:string" minOccurs="0" /> 
      <element name="tax_class_id" type="xsd:string" minOccurs="0" /> 
      <element name="tier_price" type="typens:catalogProductTierPriceEntityArray" minOccurs="0" /> 
      <element name="meta_title" type="xsd:string" minOccurs="0" /> 
      <element name="meta_keyword" type="xsd:string" minOccurs="0" /> 
      <element name="meta_description" type="xsd:string" minOccurs="0" /> 
      <element name="custom_design" type="xsd:string" minOccurs="0" /> 
      <element name="custom_layout_update" type="xsd:string" minOccurs="0" /> 
      <element name="options_container" type="xsd:string" minOccurs="0" /> 
      <element name="additional_attributes" type="typens:associativeArray" minOccurs="0" /> 
     </all> 
    </complexType> 

additional_attributes可能只有字符串,創建你需要有選擇的目標客戶對象。

如果您需要創建用戶選擇,你應該擴展Mage_Catalog_Model_Product_Api_V2 ::創建功能

0

可以列出所有產品的定製選項,使用catalog_product_custom_option.list,它會返回一個數組。

if(true == (boolean) $productInfo['has_options']) 
{ 
    $options = $this->call('catalog_product_custom_option.list', $this->productId); 
} 

我不知道從哪個Magento版本開始可以使用此功能,因爲它沒有記錄在任何地方。

的API定義:應用程序/代碼/核心/法師/目錄的/ etc/api.xml

請參閱my answer on "Creating Custom Options on a Product using the Magento API"對格蘭定義的API函數的更多細節。