3

I have followed the tutorial and making a simple REST API.

api2.xml FILE

<?xml version="1.0"?>
<config>
 <api2>
 <resource_groups>
 <custac translate="title" module="sharan">
 <group>sharan</group>
 <title>Abandoned Cart</title>
 <sort_order>10</sort_order>
 </custac>
 </resource_groups>
 <resources>
 <custac translate="title" module="sharan">
 <group>custac</group>
 <model>sharan/api2_restapi</model>
 <title>Abandoned cart info</title>
 <sort_order>2</sort_order>
 <privileges>
 <admin>
 <create>1</create>
 <retrieve>1</retrieve>
 <delete>1</delete>
 </admin> 
 </privileges>
 <routes>
 <route>
 <route>abcart</route>
 <action_type>entity</action_type>
 </route>
 </routes>
 <versions>1</versions>
 </custac>
 </resources>
 </api2>
</config>

Model file - Api2_Restapi

<?php 
class Ziffity_Sharan_Model_Api2_Restapi extends Mage_Api2_Model_Resource{
 public function _retrieve(){
 return json_encode(array("value"=>"Hello World"));
 }
}///end of class//
?>

V1.php file

<?php
class Ziffity_Sharan_Model_Api2_Rest_V1 extends Ziffity_Sharan_Model_Api2_Restapi{
 public function _retrieve(){
 return json_encode(array("value"=>"Hello World"));
 }
} 
?>
asked Mar 1, 2016 at 14:16

1 Answer 1

2

SOLUTION FOUND

My Folder Structure was wrong.

SHOULD BE EXACTLY LIKE BELOW TO WORK

enter image description here

The Rest Folder should have Role Type Folders inside and then the V1.php files with the respective class names.

answered Oct 5, 2016 at 7:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.