Jump to content

How to add new resource (expose category_group table) to the WebService


alirot

Recommended Posts

Hello

 

I tried this documentation https://webkul.com/blog/how-to-add-new-tables-in-rest-api-of-prestashop/

for exposing category_group table in webservice (two fields, id_category and id_group, creating in override folder class Category_Group and WebserviceRequest.php in webservice folder) but when I call localhost/local_site/api/category_group, the xml returned is empty

please help

Link to comment
Share on other sites

Prestashop version is: 1.6.1.23

Files used:

WebserviceRequest.php

<?php
class WebserviceRequest extends WebserviceRequestCore
{

public static function getResources()
{
$resources=parent::getResources();
$resources['category_group'] = array('description' => 'Expose category_group table', 'class' => 'CategoryGroup');
ksort($resources);
return $resources;
}
}
?>

CategoryGroup.php class

<?php
class CategoryGroupCore extends ObjectModel {    
  public $id_category;
    public $id_group;
    
    public static $definition = array(
    'table' => 'ps_category_group',
    'primary' => 'PRIMARY',
    'fields' => array(
            'id_category' => array('type' => self::TYPE_INT),
            'id_group' => array('type' => self::TYPE_INT)
    )
    );
    protected $webserviceParameters = array();
}
?>

 

 

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...