Author Topic: Starting with API  (Read 1632 times)

Zilvermeeuw

  • Beginner
  • *
  • Posts: 32
Starting with API
« on: May 29, 2021, 18:08:52 pm »
I would like to start learning the API of Virtuemart.

I am reading https://api.virtuemart.net, but nothing what I do works.

Does anybody have an example how to start with the API?
If I never done it, I think I am able to do it.

Zilvermeeuw

  • Beginner
  • *
  • Posts: 32
Re: Starting with API
« Reply #1 on: May 31, 2021, 06:26:44 am »
I added "include "testapi.php";" at the beginning of "administrator/components/com_virtuemart/views/orders/tmpl/orders.php". So when I open de Virtuemart orders list, the script "testapi.php" is called.

the array $this->orderslist contains all orders
the member 0 contains information about the last order ($this->orderslist[0])
The following vmJsApi works (it is a copy from orders.php)
Code: [Select]
$order = $this->orderslist[0];
echo vmJsApi::date ($order->created_on, 'LC2', TRUE) ."<br>";

In https://api.virtuemart.net several classes are given. For example the following. But this is not working (I tried several classes).
Code: [Select]
$q = VirtuemartViewOrders::display ($order);
echo "q = ". $q  .".<br>";

Also the first vmJsApi parameters, I cannot find in the api.virtuemart.net website.

I think I am on the wrong track. But where?
If I never done it, I think I am able to do it.

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1207
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Starting with API
« Reply #2 on: May 31, 2021, 10:16:16 am »
why do you need API?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

Zilvermeeuw

  • Beginner
  • *
  • Posts: 32
Re: Starting with API
« Reply #3 on: May 31, 2021, 10:32:10 am »
I would like to:
  • interface between an ERP system and Virtuemart (Orders, products, stock, clients)
  • Write an interface between several Virtuemart webshops to have products in those webshops or to move products between webshops (products, categories)
  • To learn more about programming in PHP with classes.
If I never done it, I think I am able to do it.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4489
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Starting with API
« Reply #4 on: May 31, 2021, 23:24:10 pm »
The APi is to use in Joomla. If you want connect an ERP, you have to use (joomla) plugins, you have no external APi for Virtuemart.
You have some extensions that can render a list of product with some filters, but what you want to do is a big task(hundreds Hours of dev)
I see that you do not a PHP expert, so first you have to understand MVC, Joomla and after VIrtuemart before trying to create your own API

Zilvermeeuw

  • Beginner
  • *
  • Posts: 32
Re: Starting with API
« Reply #5 on: June 01, 2021, 07:29:02 am »
I know I have to write a plugin. I already created two MVC's in Joomla. With PHP, SQL and calls to the ERP with its API. (So I am an expert wanebee, see my signature)

I like the way, an API works. Just ask some information and get an answer. Without need for knowledge of the SQL database or array structures.
To get rid of the SQL queries I would like to use API's. Therefor I made the above (very simple, without plugin) example and tried several formats of the line. But none are working.
Clearly I miss something.

Edit: If found the class vmJsApi and played around with it. This works.
I would like to use the class, mentioned in https://api.virtuemart.net/annotated.html.

How can I call these classes?
If I never done it, I think I am able to do it.

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1207
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Starting with API
« Reply #6 on: June 01, 2021, 08:53:37 am »
if you want connect ERP you have to write your custom class in your plugin.
(we connected SAP, KTK, online app on mobile with VirtueMart).

Or you can use existing solutions
- with Xml/CSV files (+ cron) - we connected Cesar, Helios
- with DB - we connected Pohoda, MoneyS4

We don't use API VM.

www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4489
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Starting with API
« Reply #7 on: June 01, 2021, 10:52:27 am »
If you click on the function details, you see that this list is only a function list of other plugins .

For eg BatchDelete :
The documentation for this class was generated from the following file:
plugins/vmcalculation/avalara/classes/BatchSvc/BatchDelete.class.php

You have no way to communicate with Vm directly using an API

Zilvermeeuw

  • Beginner
  • *
  • Posts: 32
Re: Starting with API
« Reply #8 on: June 02, 2021, 06:15:24 am »
OK, thanks.

No API, just function calls.
If I never done it, I think I am able to do it.

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1207
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Starting with API
« Reply #9 on: June 02, 2021, 10:17:39 am »
That is right
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates