自定义Prestashop Webservice CRUD方法

时间:2016-10-11 09:19:03

标签: php web-services prestashop prestashop-1.6

我正在开发一个PS模块,将asociated store数据(name,url,apiKey ...)作为一个集中的数据插入到另一个PS Store的新表中。

我已经完成了创建新的Web服务,检查GET,POST和DELETE CRUD复选框以及为我的自定义Web服务建立的Webservice Key。现在我希望通过webservice url记录新的关联商店。

我所做的是:

覆盖 webserviceRequest(覆盖/ clases / webservice / webserviceRequest.php)

class WebserviceRequest extends WebserviceRequestCore {
    public function __construct() {
        include_once(_PS_MODULE_DIR_.'mycustomwebservicedir'.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.'myCustomClassForWs.php');
    }

    public static function getResources()
    {
        $resources = parent::getResources();
        $resources['myCustomWs'] = array('description' => 'Description for my custom webservice', 'class' => 'myCustomClassForWs');
        ksort($resources);
        return $resources;
    }
}

这是我自定义类的代码( models / myCustomClassForWs.php

class myCustomClassForWs extends ObjectModel
{
    public $store_name;
    public $store_url;
    public $store_api_key;
    public $store_contact_email;

    public static $definition = [
        'table'     => _DB_PREFIX_.'mycustomtable',
        'primary'   => 'id_primary_key',
        'fields'    => [
            'store_name'            => ['type' => self::TYPE_STRING, 'required' => true],
            'store_url'             => ['type' => self::TYPE_STRING, 'required' => true],
            'store_api_key'         => ['type' => self::TYPE_STRING, 'required' => true],
            'store_contact_email'   => ['type' => self::TYPE_STRING, 'required' => true],
        ]
    ];

    protected $webserviceParameters = [];
}

所以,我的问题是,如何通过Web服务URL传递params来处理自定义web服务以插入到我的新表中。

编辑:我在尝试访问http://localhost/prestashop/prestashop-base/api/centralized_store

时添加了一段XML响应

Browser Webservice response

0 个答案:

没有答案