Extend Magento REST API in custom module

后端 未结 1 1689
我在风中等你
我在风中等你 2021-02-10 18:29

I want to use Magento Rest-Api to add custom data into Magento table. I have added one table into Magento db and created module with Rest API for that using following link

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-10 19:15

    magento\app\code\core\Mage\Api2\Model\Resource.php is only allowed collection action type for create method.. so changed in api2.xml file and setup required fields in attribute tag

    magento\app\code\community\MagePim\Extapi\etc\api2.xml

    
    
        
            
                
                    Custom API calls
                    
                        
                            My Api
                        
                    
                
            
            
                
                    extapi
                    extapi/api2
                    extapi/api2
                    Custom Api
                    
                        
                            1
                            1
                            1
                            1
                        
                    
                    
                        Owner ID
                        Identity ID
                        Social ID
                        Status
                        Text
                        Request Time
                        Status Time
                    
                    
                        
                        
                            /scheduler
                            entity
                        
                        
                        
                            /scheduler/create
                            collection
                        
                    
                    1
                
            
        
    
    

    magento\app\code\community\MagePim\Extapi\Model\Api2\Rest\Admin\V1.php

    /**
     * Override for 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'));
        }
    ....................
    }
    

    0 讨论(0)
提交回复
热议问题