1

我做了两个不同的 Magento 扩展,以便为以下 Magento 选项提供 SOAP 方法:

  • 捆绑产品关联
  • 价格组分配

我正在从 Navision (ERP) 管理我的目录,因此我准备了两个选项以兼容 WSI,使用 wsi.xml 文件。

一切都像单独使用两个 API 扩展的魅力一样,但是当我让它们都处于活动状态时,我收到一个调用第二个错误的错误,它说第一个方法的参数丢失(奇怪......)。

这是我得到的错误:

2015-02-09T17:47:59+00:00 ERR (3): 
exception 'Exception' with message 'Required parameter "item_options" is missing.' in C:\wamp\www\eltalleronline\app\code\core\Mage\Api\Model\Server\Wsi\Handler.php:171
Stack trace:
#0 C:\wamp\www\eltalleronline\app\code\core\Mage\Api\Model\Server\Wsi\Handler.php(76): Mage_Api_Model_Server_WSI_Handler->prepareArgs(Array, Array)
#1 [internal function]: Mage_Api_Model_Server_WSI_Handler->__call('bundleapiBundle...', Array)
#2 [internal function]: Mage_Api_Model_Server_WSI_Handler->bundleapiBundleapiAssign(Object(stdClass))
#3 C:\wamp\www\eltalleronline\lib\Zend\Soap\Server.php(832): SoapServer->handle('<?xml version="...')
#4 C:\wamp\www\eltalleronline\app\code\core\Mage\Api\Model\Server\Wsi\Adapter\Soap.php(88): Zend_Soap_Server->handle()
#5 C:\wamp\www\eltalleronline\app\code\core\Mage\Api\Model\Server.php(138): Mage_Api_Model_Server_WSI_Adapter_Soap->run()
#6 C:\wamp\www\eltalleronline\app\code\core\Mage\Api\controllers\V2\SoapController.php(46): Mage_Api_Model_Server->run()
#7 C:\wamp\www\eltalleronline\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Mage_Api_V2_SoapController->indexAction()
#8 C:\wamp\www\eltalleronline\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#9 C:\wamp\www\eltalleronline\app\code\community\ArtsOnIT\OfflineMaintenance\Controller\Router\Standard.php(46): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#10 C:\wamp\www\eltalleronline\app\code\core\Mage\Core\Controller\Varien\Front.php(172): ArtsOnIT_OfflineMaintenance_Controller_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 C:\wamp\www\eltalleronline\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#12 C:\wamp\www\eltalleronline\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#13 C:\wamp\www\eltalleronline\index.php(85): Mage::run('', 'store')
#14 {main}

这是 BundleAPI wsi.xml 文件:

<?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:complexType name="bundleapiBundleapiItem">
                <xsd:sequence>
                    <xsd:element name="title" type="xsd:string" minOccurs="0" />
                    <xsd:element name="option_id" type="xsd:string" minOccurs="0" />
                    <xsd:element name="delete" type="xsd:string" minOccurs="0" />
                    <xsd:element name="type" type="xsd:string" minOccurs="0" />
                    <xsd:element name="required" type="xsd:string" minOccurs="0" />
                    <xsd:element name="position" type="xsd:string" minOccurs="0" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="bundleapiBundleapiOptions">
                <xsd:sequence>
                    <xsd:element name="product_id" type="xsd:string" minOccurs="0" />
                    <xsd:element name="selection_id" type="xsd:string" minOccurs="0" />
                    <xsd:element name="option_id" type="xsd:string" minOccurs="0" />
                    <xsd:element name="delete" type="xsd:string" minOccurs="0" />
                    <xsd:element name="selection_price_value" type="xsd:string" minOccurs="0" />
                    <xsd:element name="selection_price_type" type="xsd:string" minOccurs="0" />
                    <xsd:element name="selection_can_change_qty" type="xsd:string" minOccurs="0" />
                    <xsd:element name="selection_qty" type="xsd:string" minOccurs="0" />
                    <xsd:element name="is_default" type="xsd:string" minOccurs="0" />
                    <xsd:element name="position" type="xsd:string" minOccurs="0" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:element name="bundleapiBundleapiAssignRequestParam">
                <xsd:complexType>
                    <xsd:sequence>
                            <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
                            <xsd:element minOccurs="1" maxOccurs="1" name="items" type="typens:bundleapiBundleapiItem" />
                            <xsd:element minOccurs="1" maxOccurs="1" name="item_options" type="typens:bundleapiBundleapiOptions" />
                            <xsd:element minOccurs="1" maxOccurs="1" name="bundle_id" type="xsd:string" />
                            <xsd:element minOccurs="1" maxOccurs="1" name="store_id" type="xsd:string" />
                        </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="bundleapiBundleapiAssignResponseParam">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="bundleapiBundleapiAssignRequest">
        <wsdl:part name="parameters" type="typens:bundleapiBundleapiAssignRequestParam"/>
    </wsdl:message>
    <wsdl:message name="bundleapiBundleapiAssignResponse">
        <wsdl:part name="parameters" type="typens:bundleapiBundleapiAssignResponseParam" />
    </wsdl:message>
    <wsdl:portType name="{{var wsdl.handler}}PortType">
        <wsdl:operation name="bundleapiBundleapiAssign">
            <wsdl:documentation>API method assign products to bundle</wsdl:documentation>
            <wsdl:input message="typens:bundleapiBundleapiAssignRequest" />
            <wsdl:output message="typens:bundleapiBundleapiAssignResponse" />
        </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="bundleapiBundleapiAssign">
            <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>

这是 PriceGroupAPI wsi.xml 文件(给我错误的那个):

<?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:complexType name="catalogProductGroupPriceEntity">
                <xsd:sequence>
                    <xsd:element name="customer_group_id" type="xsd:string" minOccurs="0" />
                    <xsd:element name="website" type="xsd:string" minOccurs="0" />
                    <xsd:element name="price" type="xsd:double" minOccurs="0" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="catalogProductGroupPriceEntityArray">
                <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="unbounded" name="complexObjectArray" type="typens:catalogProductGroupPriceEntity" />
                </xsd:sequence>
            </xsd:complexType>

            <xsd:element name="pricegroupapiPricegroupapiUpdateRequestParam">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
                        <xsd:element minOccurs="1" maxOccurs="1" name="productId" type="xsd:string" />
                        <xsd:element minOccurs="1" maxOccurs="1" name="group_price" type="typens:catalogProductGroupPriceEntityArray" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

            <xsd:element name="pricegroupapiPricegroupapiUpdateResponseParam">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:int" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="pricegroupapiPricegroupapiUpdateRequest">
        <wsdl:part name="parameters" type="typens:pricegroupapiPricegroupapiUpdateRequestParam"/>
    </wsdl:message>
    <wsdl:message name="pricegroupapiPricegroupapiUpdateResponse">
        <wsdl:part name="parameters" type="typens:pricegroupapiPricegroupapiUpdateResponseParam" />
    </wsdl:message>
    <wsdl:portType name="{{var wsdl.handler}}PortType">
        <wsdl:operation name="pricegroupapiPricegroupapiUpdate">
            <wsdl:documentation>API method assign prices to a customer group</wsdl:documentation>
            <wsdl:input message="typens:pricegroupapiPricegroupapiUpdateRequest" />
            <wsdl:output message="typens:pricegroupapiPricegroupapiUpdateResponse" />
        </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="pricegroupapiPricegroupapiUpdate">
            <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>

对第二种方法的调用是这样的:

$productId = 5813;
$tierPrices = array(
    array('customer_group_id' => '3', 'website' => '0', 'price' => '0.7989'),
    array('customer_group_id' => '6', 'website' => '0', 'price' => '0.9187')
);

try{
    $result = $proxy->pricegroupapiPricegroupapiUpdate((object)array(
        'sessionId' => $sessionId->result,
        'productId' => $productId,
        'group_price' => $tierPrices,
        'items' => NULL
    ));
}catch(SoapFault $e){
    echo "<pre>";var_dump($e);echo "</pre>";
}

我尝试到处搜索都没有成功,所以任何帮助都将不胜感激。

请随时向我询问两个模块中的任何文件。

提前致谢!

4

0 回答 0