Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Override Core-API
 
smoe
Jr. Member
 
Total Posts:  1
Joined:  2008-09-15
 

Hello,

i wonder if there is a possibility to override the methods behind the API ressources.
I tried to create a new api with success. i mapped the standard API class and everything works allright. So i thought about the possibility to rewrite a model, so i could use the standard API calls to process my own implementions, but no. won’t work as i suggested. maybe its not possible because API-calls are different handled than standard php-classes. maybe (or hopefully) i have overseen something or did something wrong. could anybody help, please?

api.xml:

<config>
    <
api>
        <
resources>
            <
advancedapi_product translate="title" module="advancedapi">
                <
title>Advanced Product API</title>
                <
model>advancedapi/product_api</model>
                <
acl>catalog/product_api</acl>
                <
methods>
                    <list 
translate="title" module="advancedapi">
                        <
title>List Products</title>
                        <
method>items</method>
                    </list>
                </
methods>
            </
advancedapi_product>
        </
resources>
        <
resources_alias>
            <
product>advancedapi_product</product>
        </
resources_alias>
        <
acl>
            <
resources>
                <
all>
...
                </
all>
            </
resources>
        </
acl>
    </
api>
</
config>

config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <
modules>
       <
Company_AdvancedAPI>
          <
version>0.1.0</version>
       </
Company_AdvancedAPI>
    </
modules>
    <global>
        <
models>
            <
advancedapi>
                <class>
Company_AdvancedAPI_Model</class>
            </
advancedapi>
         </
models>
         <
catalog>
             <
product_api>
                <
rewrite>Company_AdvancedAPI_Model_Product_Api</rewrite>
            </
product_api>
        </
catalog>
    </global>
</
config>

This is how i call it:

$proxy = new SoapClient('http://localhsot/magento/index.php/api/soap/?wsdl');
$sessionId $proxy->login('apiuser''apikey');

// this call of my own implementation works fine
$products $proxy->call($sessionId'advancedapi_product.list');
var_dump($products);

// this call of the standard implementation only processes the standard api implementation
// my rewrite in config.xml is ignored
$products $proxy->call($sessionId'product.list');
var_dump($products);

thanks in advance for help

ciao
smoe

 
Magento Community Magento Community
Magento Community
Magento Community
 
gunardiwu
Jr. Member
 
Total Posts:  13
Joined:  2008-03-14
 

Edit your config.xml and move the <catalog> block and place it under <models> since you are overriding the models

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top