Magento API向catalogProductCreateEntity添加新的复杂类型(未传递额外属性)

时间:2013-02-15 14:58:01

标签: api magento soap

我正在尝试扩展magento以传递可配置的产品。我希望通过扩展catalogProductCreateEntity来做到这一点。我所做的是创建了我自己的模块,并通过在<types>标记中添加以下内容来扩展目录模块wsdl。像这样...

        <complexType name="catalogProductCreateEntity">
            <all>
                <element name="categories" type="typens:ArrayOfString" minOccurs="0" />
                <element name="websites" type="typens:ArrayOfString" minOccurs="0" />
                <element name="associated" type="typens:ArrayOfString" minOccurs="0" />
                <element name="super_attributes" type="typens:catalogProductLinkEntityArray" 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:ArrayOfString" 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>
        <complexType name="catalogProductSuperAttributeEntity">
            <all>
                <element name="attribute_id" type="xsd:string" minOccurs="0"/>
                <element name="product_super_attribute_id" type="xsd:string" minOccurs="0"/>
                <element name="product_id" type="xsd:string" minOccurs="0"/>
                <element name="position" type="xsd:string" minOccurs="0"/>
                <element name="label" type="xsd:string" minOccurs="0"/>
                <element name="attribute_code" type="xsd:string" minOccurs="0"/>
                <element name="use_default" type="xsd:string" minOccurs="0"/>
                <element name="prices" type="xsd:string" minOccurs="0"/>
            </all>
        </complexType>
        <complexType name="catalogProductSuperAttributeEntityArray">
            <complexContent>
                <restriction base="soapenc:Array">
                    <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:catalogProductSuperAttributeEntity[]"/>
                </restriction>
            </complexContent>
        </complexType>

我在catalogProductCreateEntity中创建了一个名为super属性的新元素。它的类型是catalogProductSuperAttributeEntityArray,它是catalogProductSuperAttributeEntity的数组,我也在上面定义了它。当我打电话给肥皂服务器时,我这样做......

            foreach($prodInfo->super_attributes as $super_att) {
                $sProdInfo['super_attributes'][] = array(
                    'attribute_id'=>$super_att->attribute_id,
                    'product_super_attribute_id'=>$super_att->product_super_attribute_id,
                    'product_id'=>$super_att->product_id,
                    'position'=>$super_att->position,
                    'label'=>$super_att->label,
                    'attribute_code'=>$super_att->attribute_code,
                    'use_default'=>$super_att->use_default,
                    'prices'=>12
                );
            }

填充所有元素。它看起来像这样......

[super_attributes] => Array
    (
        [0] => Array
            (
                [attribute_id] => 159
                [product_super_attribute_id] => 207
                [product_id] => 4659
                [position] => 0
                [label] => Shirt Size
                [attribute_code] => shirt_size
                [use_default] => 0
                [prices] => 12
            )

        [1] => Array
            (
                [attribute_id] => 70
                [product_super_attribute_id] => 208
                [product_id] => 4659
                [position] => 0
                [label] => Manufacturer
                [attribute_code] => manufacturer
                [use_default] => 0
                [prices] => 12
            )

    )

现在,我还扩展了Mage_Catalog_Model_Product_Api_V2类来处理这个新属性。我的问题是当我单步执行代码时,magento只接收数组中的2个属性。

  1. PRODUCT_ID
  2. 位置
  3. 忽略所有其他属性。我还清空了服务器和客户端上的soap缓存,但似乎没有任何改变。

1 个答案:

答案 0 :(得分:0)

想出来......

<element name="super_attributes" type="typens:catalogProductLinkEntityArray" minOccurs="0" />

应该是我新创建的typens ...

<element name="super_attributes" type="typens:catalogProductSuperAttributeEntityArray" minOccurs="0" />

在复杂类型catalogProductCreateEntity