Я создал индивидуальные API для magento. Некоторые встроенные вызовы API, например «catalogCategoryTree», выдающие ошибку: «Неверный путь API» ниже — это файлы, которые я создал для пользовательских API.
api.xml
<?xml version="1.0"?>
<config>
<api>
<resources>
<masterapi_loginmodel translate="title" module="masterapi">
<model>masterapi/loginmodel_api</model>
<title>Demo Custommoduleapi API</title>
<acl>masterapi/loginmodel</acl>
<methods>
<!-- <list translate="title" module="masterapi">
<title>List of masterapi</title>
<method>clogin</method>
</list> -->
<customerlogin translate="title" module="masterapi">
<title>List of masterapi</title>
</customerlogin>
</methods>
</masterapi_loginmodel>
<masterapi_category translate="title" module="masterapi">
<model>masterapi/category_api</model>
<title>Demo category API</title>
<acl>masterapi/category</acl>
<methods>
<!-- <list translate="title" module="masterapi">
<title>List of masterapi</title>
<method>clogin</method>
</list> -->
<getCat translate="title" module="masterapi">
<title>List of filters</title>
</getCat>
<getCProductinfo translate="title" module="masterapi">
<title>List of filters</title>
</getCProductinfo>
</methods>
</masterapi_category>
<masterapi_catproduct translate="title" module="masterapi">
<model>masterapi/catproduct_api</model>
<title>Demo Catproduct API</title>
<acl>masterapi/catproduct</acl>
<methods>
<!-- <list translate="title" module="masterapi">
<title>List of masterapi</title>
<method>clogin</method>
</list> -->
<getCat translate="title" module="masterapi">
<title>List of filters</title>
</getCat>
</methods>
</masterapi_catproduct>
</resources>
<resources_alias>
<loginmodel>masterapi_loginmodel</loginmodel>
<category>masterapi_category</category>
<catproduct>masterapi_catproduct</catproduct>
</resources_alias>
<v2>
<resources_function_prefix>
<loginmodel>masterapiLoginmodel</loginmodel>
<category>masterapiCategory</category>
<catproduct>masterapiCatproduct</catproduct>
</resources_function_prefix>
</v2>
<acl>
<resources>
<masterapi translate="title" module="masterapi">
<title>Loginmodel</title>
<sort_order>5</sort_order>
<loginmodel translate="title" module="masterapi">
<title>loginmodel data</title>
</loginmodel>
<category translate="title" module="masterapi">
<title>loginmodel data</title>
</category>
<catproduct translate="title" module="masterapi">
<title>loginmodel data</title>
</catproduct>
</masterapi>
</resources>
</acl>
</api>
</config>
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycustom_Masterapi>
<version>1.0</version>
</Mycustom_Masterapi>
</modules>
<global>
<models>
<masterapi>
<class>Mycustom_Masterapi_Model</class>
<rewrite>
<product>Mycustom_Masterapi_Model_Catproduct</product>
</rewrite>
</masterapi>
</models>
<helpers>
<masterapi>
<class>Mycustom_Masterapi_Helper</class>
</masterapi>
</helpers>
</global>
</config>
wsdl.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/" xmlns="http://schemas.xmlsoap.org/wsdl/"name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
<complexType name="filterInfo">
<sequence>
<element name="filterName" type="xsd:string"/>
<element name="name" type="xsd:string[]"/>
</sequence>
</complexType>
<complexType name="fieldInfo">
<sequence>
<element name="entity_id" type="xsd:string"/>
<element name="name" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="fieldInfoArray">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="typens:fieldInfo[]" />
</restriction>
</complexContent>
</complexType>
<!---Declare our types-->
<complexType name="catalogCategoryID">
<sequence>
<element name="category_id" type="xsd:string" />
<element name="category_name" type="xsd:string" />
</sequence>
</complexType>
<!---Declare our input and output parameters-->
<element name="catalogCategoryGetIDRequestParam">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
<element minOccurs="1" maxOccurs="1" name="category_name" type="xsd:string" />
</sequence>
</complexType>
</element>
<element name="catalogCategoryGetIDResponseParam">
<complexType>
<sequence>
<!---here we use the type we declared earlier as our output parameter-->
<element minOccurs="1" maxOccurs="1" name="result" type="typens:catalogCategoryID" />
</sequence>
</complexType>
</element>
<!---Boohoo-->
</schema>
</types>
<!-- message -->
<message name="masterapiLoginmodelListRequest">
<part name="sessionId" type="xsd:string" />
<part name="user" type="xsd:string" />
<part name="pass" type="xsd:string" />
</message>
<message name="masterapiLoginmodelListResponse">
<part name="customlogin" type="xsd:string" />
</message>
<message name="masterapiCategoryCustomerloginRequest">
<part name="sessionId" type="xsd:string" />
<part name="category_name" type="xsd:string" />
</message>
<message name="catalogCategoryGetIDResponse">
<part name="parameters" type="xsd:array" />
</message>
<!-- Product info Msg -->
<message name="masterapiCategoryGetCProductinfoRequest">
<part name="sessionId" type="xsd:string" />
<part name="category_cat_id" type="xsd:int" />
</message>
<message name="masterapiCategoryGetCProductinfoResponse">
<part name="parameters" type="xsd:array" />
</message>
<!-- END Product info Msg -->
<!-- portType 2nd -->
<portType name="{{var wsdl.handler}}PortType">
<operation name="masterapiLoginmodelCustomerlogin">
<documentation>List of masterapi</documentation>
<input message="typens:masterapiLoginmodelListRequest" />
<output message="typens:masterapiLoginmodelListResponse" />
</operation>
<operation name="masterapiCategoryGetCat">
<documentation>List of masterapi</documentation>
<input message="typens:masterapiCategoryCustomerloginRequest" />
<output message="typens:catalogCategoryGetIDResponse" />
</operation>
<operation name="masterapiCategoryGetCProductinfo">
<documentation>List of masterapi</documentation>
<input message="typens:masterapiCategoryGetCProductinfoRequest" />
<output message="typens:masterapiCategoryGetCProductinfoResponse" />
</operation>
<operation name="masterapiCatproductGetCat">
<documentation>List of masterapi</documentation>
<input message="typens:masterapiCategoryCustomerloginRequest" />
<output message="typens:catalogCategoryGetIDResponse" />
</operation>
</portType>
<!-- binding 1st -->
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="masterapiLoginmodelCustomerlogin">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="masterapiCategoryGetCat">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="masterapiCategoryGetCProductinfo">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="masterapiCatproductGetCat">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="{{var wsdl.name}}Service">
<port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
<soap:address location="{{var wsdl.url}}" />
</port>
</service>
</definitions>
.PHP
<?php
// app/code/local/Mycustom/Masterapi/Model/Loginmodel/Api.php
class Mycustom_Masterapi_Model_Loginmodel_Api
{
public function customerlogin($user,$pass)
{
/** @var $session Mage_Customer_Model_Session */
$session = Mage::getSingleton( 'customer/session' );
Mage::app()->getStore()->setWebsiteId(1);
try
{
$session->login( $user, $pass);
$customer = $session->getCustomer();
return json_encode(array('status' => 'valid', 'userData' => $customer->getId()));
}
catch( Exception $e )
{
return json_encode(array('status' => 'invalid', 'userData' => $e->getMessage()));
}
// return $arr_products;
//return 'true'.$user.'+'.$pass;
}
}
V2.php
Mycustom_Masterapi_Model_Loginmodel_Api
{
}
Задача ещё не решена.
Других решений пока нет …