How To Extend Api

Hi,

I'm following this guide at http://docs.cs-cart.com/4.3.x/api/extending_with_addons.html. However, I'm still not able to extend the standard API. The guide says "In the add-on directory, create the subdirectories Tygh/Api/Entities".

Where is the "add-on directory?"

I've copied the code and created the file Things.php at:

/app/addons

/Tygh/Addons

/Tygh/Api/Entities

But none of it works. The error returned Things entity is not found. Is the guide complete? Are there more files to be created?

The correct path is

app/addons/your_addon_name/Tygh/Api/Entities

The correct path is

app/addons/your_addon_name/Tygh/Api/Entities

This is not working as well. You can see I've created the folder and .php file.

CZgLC0F.jpg

I still get the error:

{
"message": "Not Found: The Entity Things not found",
"status": 404
}

Try to use built-in call requests entity as example:

app/addons/call_requests/Tygh/Api/Entities/CallRequests.php

Try to use built-in call requests entity as example:

app/addons/call_requests/Tygh/Api/Entities/CallRequests.php

Still can't. I believe there are more things that needs to be done but it is not clearly documented in CS-Cart's API documentation.

Try to copy permissions part from the CallRequests.php file. Someone posted recently that this code can be required

Yes , i have same problem but i'm not getting any solution .

We will take a look at this and provide you with a solution.

We will take a look at this and provide you with a solution.

Thank you. I hope to receive a detailed guide on how to extend the API.

For your info, I've also tried to duplicate app/Tygh/Api/Entities/Auth.php to a new API name in the same folder. Then, I make the usual REST request to the new API name, I get the same error as well, entity not found.

Are you sure that the module is installed and activated? Strange question, but such things happen

Are you sure that the module is installed and activated? Strange question, but such things happen

I don't have a module, because I just want to extend the API to have more functionalities. Or I must have a module? The documentation didn't mention anything about having a module. Please advise.

I don't have a module, because I just want to extend the API to have more functionalities. Or I must have a module? The documentation didn't mention anything about having a module. Please advise.

Sure, new module is necessary for this feature. At least use the default My changes module

Hi,

I'm following this guide at http://docs.cs-cart.com/4.3.x/api/extending_with_addons.html. However, I'm still not able to extend the standard API. The guide says "In the add-on directory, create the subdirectories Tygh/Api/Entities".

Hello,

Unfortunately, the link you used is out of date; here's the latest version of the article: http://docs.cs-cart.com/4.3.x/developer_guide/addons/api_extending.html

The article has also been updated to answer some of your questions. I hope you will find it more useful now. The part about the add-on was probably omitted because the article itself was in the Add-on Development section of the documentation.

If that's what caused the confusion, I apologize for the inconvenience.

P.S. In the Russian version of CS-Cart add-ons are called "modules". I just thought I should point that out to avoid a possible misunderstanding.

I've managed to extend the API! Special thanks to eComLabs and ikoshkin. It's great to receive great support from you. I truly appreciate it.

Hi,

How do I extend the API with a custom subfolder like abc.com/api/custom/products ?

Also is it possible to extend the base class to just modify part of the code needed ?

I've tried to copy the code from Tygh\Api\v20\Products.php to use in the add-on class Products2.php and change the class name to Product2 but getting the following errors

Cannot declare class Tygh\Api\Entities\v20\Products2, because the name is already in use in /app/addons/api_ext/Tygh/Api/Entities/Products2.php on line 0

Found the problem lies with me forgetting to change the namespace.

But still don't know how to extend the API with a custom subfolder like abc.com/api/custom/products ?