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

Problem Overriding Catalog/Category/Api class - local api.xml not taking effect
 
Jamie McKenzie
Jr. Member
 
Total Posts:  1
Joined:  2010-06-28
 

I am overriding the Mage_Catalog_Model_Category_Api class and have added a function called “assignedProductsDetail” which returns an array of products assigned to that category in more detail than the standard “assignedProducts” function.

I seem to have an issue with the additional method not being made available to the catalog_category api call when configured in the local api.xml (app/code/local/MyModule/Catalog/etc/api.xml).

It works if I add the method “assignedProductsDetail” to the core api.xml (app/code/core/Mage/Catalog/etc/api.xml) which obviously I want to avoid doing.

Here is my code:

Path: etc/modules/MyModule_Category.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyModule_Catalog>
            <
active>true</active>
            <
codePool>local</codePool>
        </
MyModule_Catalog>
    </
modules>
</
config>

Path: app/code/local/MyModule/Category/etc/api.xml

<?xml version="1.0"?>
<config>
    <
api>
        <
resources>
            <
catalog_category translate="title" module="catalog">
                <
title>My Custom Category API</title>
                <
model>catalog/category_api</model>
                <
methods>
                    <
assignedProductsDetail translate="title" module="catalog">
                        <
title>Retrieve detailed list of assigned products to category</title>
                        <
acl>catalog/category/product</acl>
                    </
assignedProductsDetail>
                </
methods>
            </
catalog_catgory>    
        </
resources>
        <
resources_alias>
            <
category>catalog_category</category>
        </
resources_alias>
        <
v2>
            <
resources_function_prefix>
                <
category>catalogCategory</category>
            </
resources_function_prefix>
        </
v2>
    </
api>
</
config>

Path: app/code/local/MyModule/Category/etc/config.xml

<?xml version="1.0"?>
<config>
 <
modules>
    <
MyModule_Catalog>
      <
version>0.0.1</version>
      <
depends>
        <
Mage_Catalog />
      </
depends>
    </
MyModule_Catalog>
  </
modules>
  <global>
        <
models>
            <
catalog>
                <
rewrite>
                    <
category_api>MyModule_Catalog_Model_Category_Api</category_api>
                    <
category_api_v2>MyModule_Catalog_Model_Category_Api_v2</category_api_v2>
                </
rewrite>
            </
catalog>
        </
models>
    </global>
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
EcomDev
Sr. Member
 
Avatar
Total Posts:  122
Joined:  2010-03-17
Ukraine, Kyiv
 

You’ve put depends statement in wrong place, it should be in the module bootstrap file, because modules depends sorted before loading of the module config file.
so your etc/modules/MyModule_Category.xml should looks like the following code:

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyModule_Catalog>
            <
active>true</active>
            <
codePool>local</codePool>
            <
depends>
                    <
Mage_Catalog />
            </
depends>
        </
MyModule_Catalog>
    </
modules>
</
config>

Also if you’re using SOAP, you should also add wsdl.xml into your module configuration folder, and define your custom method there, because SOAP server starts on merged file. And don’t forget to clean api configuration cache.

 
Magento Community Magento Community
Magento Community
Magento Community
 
EcomDev
Sr. Member
 
Avatar
Total Posts:  122
Joined:  2010-03-17
Ukraine, Kyiv
 

Also I’ve found out from your post that the module name and its folder name is different but should be the same. MyModule_Catalog name of module and MyModule/Category its folder. It is also could be an issue.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nsaliu
Jr. Member
 
Total Posts:  3
Joined:  2010-07-06
 

Hi, I’m searching for a solution.

I create a new custom module, and I want to expose some methods by v2 soap api, but nothing to do....the method appear in the general wsdl, but i receive this error an errore like: ‘Procedure not found....’

I follow your how-to, but nothing, the method not appear in the general wsdl…

Have you found a solution?
Magento team...where are you???

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