次の Magento オプションの SOAP メソッドを使用するために、2 つの異なる Magento 拡張機能を作成しました。
- バンドル製品の関連付け
- 価格グループの割り当て
私は Navision (ERP) からカタログを管理しているので、wsi.xml ファイルを使用して、WSI 準拠の互換性を持つように 2 つのオプションを準備しました。
両方の API 拡張機能を別々に使用すると、すべてが魔法のように機能しますが、両方をアクティブにすると、2 番目のメソッドの呼び出しでエラーが発生し、最初のメソッドのパラメーターが欠落しているというメッセージが表示されます (奇妙な...)。
これは私が得ているエラーです:
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>
2 番目のメソッドの呼び出しは次のように行われます。
$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>";
}
どこでも検索してみましたが成功しませんでしたので、助けていただければ幸いです。
両方のモジュールのファイルについてお気軽にお問い合わせください。
前もって感謝します!