php - Extend Magento REST API in custom module -


i want use magento rest-api add custom data magento table. have added 1 table magento db , created module rest api using following link

http://web.archive.org/web/20130512072025/http://magepim.com/news/extending-the-magento-rest-api-part-1_13

now want add data magento table using rest api...

what need changed in api.xml/api2.xml or in v1.php file.

kindly me have tried many codes using reference of product api2.xml file. no luck.

when run following url

http://magento-host/api/rest/magepim/products/count 

it executed v1.php file's _retrieve() function how call _create() function using php restapi oauth

magento\app\code\core\mage\api2\model\resource.php allowed collection action type create method.. changed in api2.xml file , setup required fields in attribute tag

magento\app\code\community\magepim\extapi\etc\api2.xml

<?xml version="1.0"?> <config>     <api2>         <resource_groups>             <extapi translate="title" module="api2">                 <title>custom api calls</title>                 <children>                     <extapi translate="title" module="api2">                         <title>my api</title>                     </extapi>                 </children>             </extapi>         </resource_groups>         <resources>             <extapi translate="title" module="api2">                 <group>extapi</group>                 <model>extapi/api2</model>                 <working_model>extapi/api2</working_model>                 <title>custom api</title>                 <privileges>                     <admin>                         <create>1</create>                         <retrieve>1</retrieve>                         <update>1</update>                         <delete>1</delete>                     </admin>                 </privileges>                 <attributes>                     <owner_id>owner id</owner_id>                     <identityid>identity id</identityid>                     <social_id>social id</social_id>                     <status>status</status>                     <text>text</text>                     <request_timestamp>request time</request_timestamp>                     <status_timestamp>status time</status_timestamp>                 </attributes>                 <routes>                     <!-- call v1.php _retrieve() -->                     <route_entity>                         <route>/scheduler</route>                         <action_type>entity</action_type>                     </route_entity>                     <!-- call v1.php _create() -->                     <route_collection>                         <route>/scheduler/create</route>                         <action_type>collection</action_type>                     </route_collection>                 </routes>                 <versions>1</versions>             </extapi>         </resources>     </api2> </config> 

magento\app\code\community\magepim\extapi\model\api2\rest\admin\v1.php

/**  * override magento's rest api  */ class magepim_extapi_model_api2_rest_admin_v1 extends mage_api2_model_resource {      protected function _retrieve(){         return json_encode($shedulerdata);     }     protected function _create($shedulerdata){         return json_encode($shedulerdata);     }     protected function _retrievecollection(){         return json_encode(array('method'=>'_retrievecollection'));     } .................... } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -