1

I am trying to call catalogProductAttributeAddOption with V2 of Magento's API with compliance mode enabled but am getting:

call to undefined method stdClass::catalogProductAttributeAddOption()

My immediate observation was that this method is not present as soon as compliance mode is switched on. Therefore, I added (what I think are) the correct nodes to a wsi.xml file within a custom module:

<xsd:element name="catalogProductAttributeAddOptionRequestParam">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
                    <xsd:element minOccurs="1" maxOccurs="1" name="attribute" type="xsd:string"/>
                    <xsd:element minOccurs="0" maxOccurs="1" name="data" type="typens:catalogProductAttributeOptionEntityToAdd"/>
                </xsd:sequence>
            </xsd:complexType>
</xsd:element>

etc..

This ensures that the method is displayed within the WSDL and matches the same pattern as other existing methods.

Now I am just trying to figure out where this method actually needs to be defined. Am I right in thinking there should be a Api2.php file within Catalog/Model where this should happen?

Is this method already defined somewhere to work without compliance mode which could be modified? I have searched globally and can't find a thing

2

There is no need to modify any source file as implementation for WS-I and non WS-I modes is the same. However service description is different. You need to merge the following content into Mage/Catalog/etc/wsi.xml that will enable catalogProductAttributeAddOption() method in WS-I mode:

    <?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
             name="{{var wsdl.name}}"
             targetNamespace="urn:{{var wsdl.name}}">
    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
            <xsd:element name="catalogProductAttributeAddOptionRequestParam">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
                        <xsd:element minOccurs="1" maxOccurs="1" name="attribute" type="xsd:string" />
                        <xsd:element minOccurs="1" maxOccurs="1" name="data" type="typens:catalogProductAttributeOptionEntityToAdd" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="catalogProductAttributeAddOptionResponseParam">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="catalogProductAttributeAddOptionRequest">
        <wsdl:part name="parameters" element="typens:catalogProductAttributeAddOptionRequestParam" />
    </wsdl:message>
    <wsdl:message name="catalogProductAttributeAddOptionResponse">
        <wsdl:part name="parameters" element="typens:catalogProductAttributeAddOptionResponseParam" />
    </wsdl:message>
    <wsdl:portType name="{{var wsdl.handler}}PortType">
        <wsdl:operation name="catalogProductAttributeAddOption">
            <wsdl:documentation>Add option to attribute</wsdl:documentation>
            <wsdl:input message="typens:catalogProductAttributeAddOptionRequest" />
            <wsdl:output message="typens:catalogProductAttributeAddOptionResponse" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="catalogProductAttributeAddOption">
            <soap:operation soapAction="" />
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="{{var wsdl.name}}Service">
        <wsdl:port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
            <soap:address location="{{var wsdl.url}}" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
1

Inchoo have a pretty good article on extending the V2 API which may help: http://inchoo.net/ecommerce/magento/magento-api-v2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.