문제

How to get value of core_config_data eg. general/region/state_required using Magento soap api?

도움이 되었습니까?

해결책

Create A Custommodule:

Api File(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;
        }
}

and etc/api.xml is

<?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>

You can access by below 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'));

Edit: Full module

app/code/local/Amit/Customapi/etc/
File:config.xml and 

code of this file:

<?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> 

다른 팁

You can't.

But what you can do is create your own SOAP API callable function/extend SOAP API.

The (current) details are published here: http://www.magentocommerce.com/api/soap/create_your_own_api.html

Then you can make Magento do what you need.

There may be a module out there already that exposes parts if not the whole of core_config_data but it's unlikely!

The Core Config Data is a odd one to expose on the API as it contains most of the keys to the empire. So if you do extend to get data from here, make sure it's read only and restrict it to a set of keys. Say general/region/*

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top