Как получить данные конфигурации ядра с помощью api soap Magento?
Как получить значение core_config_data, например. general/region/state_required
используя api мыла Magento?
2 answers
Создайте Пользовательский Модуль:
Файл Api(Api.php)
<?php
class Amit_Customapi_Model_Api extends Mage_Api_Model_Resource_Abstract
{
public function myregion()
{
$countryList = explode(',', Mage::getStoreConfig(general/region/state_required));
return $countryList;
}
}
И etc/api.xml является
<?xml version="1.0"?>
<config>
<api>
<resources>
<customapi_api translate="title" module="customapi">
<title>Myapi</title>
<acl>customapi/api</acl>
<model>customapi/api</model>
<methods>
<myregion translate="title" module="customapi">
<title>Require Region</title>
<acl>customapi/myregion</acl>
</myregion>
</methods>
</customapi_api>
</resources>
<acl>
<resources>
<customapi translate="title" module="customapi">
<title>Customapi</title>
<sort_order>2000</sort_order>
<myregion translate="title" module="customapi">
<title>Require Region</title>
</myregion>
</customapi>
</resources>
</acl>
</api>
</config>
Вы можете получить доступ по нижеприведенному URL-адресу
SOAP
$client = new SoapClient('http://yourhost/api/soap/?wsdl');
$session = $client->login('******', '******');
$date = $client->call($session, 'customapi_api.myregion');
XML-RPC
$client = new Zend_XmlRpc_Client('http://yourhost/api/xmlrpc/');
$session = $client->call('login', array('******', '******'));
$date=$client->call('call', array($session, 'customapi_api.myregion'));
Редактировать: Полный модуль
app/code/local/Amit/Customapi/etc/
File:config.xml and
Код этого файла:
<?xml version="1.0"?>
<config>
<modules>
<Amit_Customapi>
<version>0.1.0</version>
</Amit_Customapi>
</modules>
<global>
<helpers>
<customapi>
<class>Amit_Customapi_Helper</class>
</customapi>
</helpers>
<models>
<customapi>
<class>Amit_Customapi_Model</class>
<resourceModel>customapi_mysql4</resourceModel>
</customapi>
</models>
</global>
</config>
Ты не можешь.
Но что вы можете сделать, так это создать свою собственную вызываемую функцию SOAP API/расширить SOAP API.
(текущие) подробности опубликованы здесь: http://www.magentocommerce.com/api/soap/create_your_own_api.html
Затем вы можете заставить Magento делать то, что вам нужно.
Возможно, уже существует модуль, который предоставляет части, если не все данные core_config_data, но это маловероятно!
Данные конфигурации ядра являются странными для отображения в API, поскольку они содержит большинство ключей к империи. Поэтому, если вы расширяетесь, чтобы получить данные отсюда, убедитесь, что они доступны только для чтения, и ограничьте их набором ключей. Скажите общее/регион/*