Follow steps
for the create new custom SOAP API method
Step : 1 Create file app/etc/modules/AR_CustomApi.xml
<?xml version="1.0"?>
<config>
<modules>
<AR_CustomApi>
<active>true</active>
<codePool>local</codePool>
</AR_CustomApi>
</modules>
</config>
Step : 2 Create file app/code/local/AR/CustomApi/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<AR_CustomApi>
<version>1.0.0</version>
</AR_CustomApi>
</modules>
<global>
<models>
<customapi>
<class>AR_CustomApi_Model</class>
</customapi>
<catalog>
<rewrite>
<product_attribute_set_api>AR_CustomApi_Model_Product_Attribute_Set_Api</product_attribute_set_api>
</rewrite>
</catalog>
</models>
</global>
</config>
Step : 3 Create file app/code/local/AR/CustomApi/Model/Product/Attribute/Set/Api.php
<?php
class AR_CustomApi_Model_Product_Attribute_Set_Api extends Mage_Catalog_Model_Product_Attribute_Set_Api
{
/**
* Retrieve attribute groups
*
* @return array
*/
public function groupList($attributeSetId)
{
// check if attribute set with requested id exists
/** @var $attributeSet Mage_Eav_Model_Entity_Attribute_Set */
$attributeSet = Mage::getModel('eav/entity_attribute_set')->load($attributeSetId);
if (!$attributeSet->getId()) {
$this->_fault('invalid_attribute_set_id');
}
$groups = Mage::getModel('eav/entity_attribute_group')
->getResourceCollection()
->setAttributeSetFilter($attributeSet->getId())
->setSortOrder()
->load();
$result = array();
foreach ($groups as $group) {
$result[] = array(
'group_id' =>$group->getAttributeGroupId(),
'name' => $group->getAttributeGroupName(),
);
}
return $result;
}
}
Step : 4 Create file app/code/local/AR/CustomApi/etc/api.xml
<?xml version="1.0"?>
<config>
<api>
<resources>
<catalog_product_attribute_set translate="title" module="catalog">
<methods>
<groupList translate="title" module="catalog">
<title>Retrieve groups from attribute set</title>
<acl>catalog/product/attribute/set/group_list</acl>
</groupList>
</methods>
</catalog_product_attribute_set>
</resources>
<acl>
<resources>
<catalog translate="title" module="catalog">
<product translate="title" module="catalog">
<attribute translate="title" module="catalog">
<set translate="title" module="catalog">
<group_list translate="title" module="catalog">
<title>Groups list</title>
</group_list>
</set>
</attribute>
</product>
</catalog>
</resources>
</acl>
</api>
</config>
Step : 5 Create file app/code/local/AR/CustomApi/etc/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="catalogProductAttributeSetGroupEntity">
<all>
<element name="group_id" type="xsd:int" minOccurs="0"/>
<element name="name" type="xsd:string" minOccurs="0"/>
</all>
</complexType>
<complexType name="catalogProductAttributeSetGroupEntityArray">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="typens:catalogProductAttributeSetGroupEntity[]"/>
</restriction>
</complexContent>
</complexType>
</schema>
</types>
<message name="catalogProductAttributeSetGroupListRequest">
<part name="sessionId" type="xsd:string"/>
</message>
<message name="catalogProductAttributeSetGroupListResponse">
<part name="result" type="typens:catalogProductAttributeSetGroupEntityArray"/>
</message>
<portType name="{{var wsdl.handler}}PortType">
<operation name="catalogProductAttributeSetGroupList">
<documentation>Retrieve product attribute groups</documentation>
<input message="typens:catalogProductAttributeSetGroupListRequest"/>
<output message="typens:catalogProductAttributeSetGroupListResponse"/>
</operation>
</portType>
<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="catalogProductAttributeSetGroupList">
<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>
Step : 6 Create file app/code/local/AR/CustomApi/etc/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="catalogProductAttributeSetGroupEntity">
<xsd:sequence>
<xsd:element name="group_id" type="xsd:int" minOccurs="0" />
<xsd:element name="name" type="xsd:string" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="catalogProductAttributeSetGroupEntityArray">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="complexObjectArray" type="typens:catalogProductAttributeSetGroupEntity" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="catalogProductAttributeSetGroupListRequest">
<wsdl:part name="parameters" element="typens:catalogProductAttributeSetGroupListRequestParam" />
</wsdl:message>
<wsdl:message name="catalogProductAttributeSetGroupListResponse">
<wsdl:part name="parameters" element="typens:catalogProductAttributeSetGroupListResponseParam" />
</wsdl:message>
<wsdl:portType name="{{var wsdl.handler}}PortType">
<wsdl:operation name="catalogProductAttributeSetGroupList">
<wsdl:documentation>Retrieve product attribute set groups</wsdl:documentation>
<wsdl:input message="typens:catalogProductAttributeSetGroupListRequest" />
<wsdl:output message="typens:catalogProductAttributeSetGroupListResponse" />
</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="catalogProductAttributeSetGroupList">
<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>
Step : 7
- Go admin side
System -> Cache Management
and refresh all cache
- Go admin side
System -> Web Services -> Roles
and save all roles again
Step : 8 Called custom method like
try {
$attributeSetId = 4;
$client = new SoapClient('http://magento.com/test/index.php/api/?wsdl'); // api url
$sessionId = $client->login('ar123', 'ar123'); // API user name & key
$result = $client->call($sessionId, 'catalog_product_attribute_set.groupList',$attributeSetId);
echo "<pre>";
}
catch (Exception $e) {
echo $e->getMessage();
}
print_r($result);
$client->call($session,'product_attribute_set.groupRemove',array($attribute_id));
but still the question exists that how would I know that particular group (id) is existing in magento or not byt SOAP API. Thanks