ossedkk Posted April 11, 2016 Share Posted April 11, 2016 Hello, We are trying to add a new webservice resource from a module. We can add it as a resource in the backend, so it's visible. But we can't reach it on the url: http://example.com/api/quickpay/ We get 500 internal error. We can access all the default webservice resources of course. Here is the code for the module: <?php class QuickpayAPICore extends ObjectModel { public $exec_id; public $id_cart; public $trans_id; public $order_id; public static $definition = array( 'table' => 'quickpay_execution', 'primary' => 'exec_id', 'fields' => array( 'exec_id' => array('type' => self::TYPE_INT, 'required' => true), 'id_cart' => array('type' => self::TYPE_INT, 'required' => true), 'trans_id' => array('type' => self::TYPE_INT), 'order_id' => array('type' => self::TYPE_STRING) ) ); protected $webserviceParameters = array(); } ?> Placed: /modules/quickpay/override/classes Filename: QuickpayAPI.php The webservice: <?php class WebserviceRequest extends WebserviceRequestCore { public static function getResources(){ $resources = parent::getResources(); $resources['quickpay'] = array('description' => 'Quikpay Details', 'class' => 'QuickpayAPI'); ksort($resources); return $resources; } } ?> Placed: /modules/quickpay/override/classes/webservice Filename: WebserviceRequest.php So why can't we reach the resource. We have added it to the API account. What are we missing here to be able to access these resouces via webservice? Link to comment Share on other sites More sharing options...
ossedkk Posted April 11, 2016 Author Share Posted April 11, 2016 We get error with DEBUG mode enabled: Fatal error: Class 'QuickpayAPI' not found in /var/www/example.com/public_html/classes/webservice/WebserviceRequest.php on line 479 Link to comment Share on other sites More sharing options...
ossedkk Posted April 11, 2016 Author Share Posted April 11, 2016 No help on this one? Should be fairly straight forward for skilled Prestashop Developers. Link to comment Share on other sites More sharing options...
herve25 Posted April 12, 2016 Share Posted April 12, 2016 Hello, As your class is in the override directory rename it "QuickpayAPI" instead of QuickpayAPICore.It may works. Regards, Link to comment Share on other sites More sharing options...
Martin Posted October 31, 2017 Share Posted October 31, 2017 I have the same issue. Which names i have to add to class of object model ? class CategoryEcommerceCore but class file without "Core" ? and add resource with: $resources['categoryecommerce'] = array('description' => 'o jacie marcin', 'class' => 'CategoryEcommerceCore'); class CategoryEcommerceCore extends ObjectModel { public $category_id; public $category_core_id; public static $definition = array( 'table' => "category_ecommerce", 'primary' => 'category_id', 'fields' => array( 'category_core_id' => array('type' => self::TYPE_INT), ) ); protected $webserviceParameters = array(); } class WebserviceRequest extends WebserviceRequestCore { /* * module: EcommerceServaq * date: 2017-10-31 13:30:46 * version: 1.0.0 */ public static function getResources(){ $resources = parent::getResources(); $resources['test'] = array('description' => 'Manage My API', 'specific_management' => true); $resources['categoryecommerce'] = array('description' => 'o jacie marcin', 'class' => 'CategoryEcommerceCore'); $mp_resource = Hook::exec('addMobikulResources', array('resources' => $resources), null, true, false); if (is_array($mp_resource) && count($mp_resource)) { foreach ($mp_resource as $new_resources) { if (is_array($new_resources) && count($new_resources)) { $resources = array_merge($resources, $new_resources); } } } ksort($resources); return $resources; } } Please answer Regards Martin Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now