Reading list Switch to dark mode

    How to add new tables in REST API of PrestaShop Webservice

    Updated 26 March 2015

    From last 2-3 days , I hitched in a problem , actually my problem was to create an entry in prestashop`s table(created by me) using webservices , but as we all know that , the webService of Prestashop includes only REST API which has very limited number of nodes(tables) for performing CRUD(Create/Read/Update/Delete) operations. I googled a lot for finding a solution, but found nothing.

    Finally, I did it by reading codes of prestashop ,also by HIT n TRY method. Now , I want to share it with all of you .May be it will help someone like me n save his/her time. Here it is,

    Table Information : (which we want to add in prestashop`s webservice)

    Table Name   : erp_product_merge
    Columns name : id , erp_product_id ,  prestashop_product_id , created_by.
    Primary key  : id

    PHP Code :  [stextbox id=”info”]save this code as ‘ProductMerge.php’ in ‘~prestashop\override\classes’ folder.[/stextbox]

    class ProductMergeCore extends ObjectModel
    
    {	public $erp_product_id;
    	public $prestashop_product_id;
    	public $created_by ;
    	public static $definition = array(
    	'table' => 'erp_product_merge',
    	'primary' => 'id',
    	'fields' => array(
    	'erp_product_id' => array('type' => self::TYPE_INT, 'required' => true),
    	'prestashop_product_id' => array('type' => self::TYPE_INT,  'required' => true),
    	'created_by' => array('type' => self::TYPE_STRING,  'required' => false, 'size' => 64),
    	),
    	);
    	protected $webserviceParameters = array();
    }

    PHP Code :  [stextbox id=”info”]save this code as ‘WebserviceRequest.php’ in ‘~prestashop\override\classes\webservice’ folder.[/stextbox]

    Searching for an experienced
    Prestashop Company ?
    Find out More
    <?php
    class WebserviceRequest extends WebserviceRequestCore
    {
    public static function getResources()
    {
    $resources=parent::getResources();
    $resources['erp_product_merges'] = array('description' => 'Test Demo', 'class' => 'ProductMerge');
    ksort($resources);
    return $resources;
    }
    }

    Now , give the permissions to this resource from prestashop`s admin panel and try to perform CRUD operations on this resource via WebServices. Enjoy !!

    [stextbox id=”warning”]Your opinions, comments and suggestions are important to keep the page updated and interesting. [/stextbox]

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    17 comments

  • Prakash
    • Mohit Chandra (Moderator)
  • Ed
  • Michel Conrado Diz
    • Mohit Chandra
  • miguel.garcia.c10
    • Mohit Chandra
  • Pranay Goyal
    • Mohit Chandra
      • kiruba
        • Mohit Chandra
  • Francisco Arturo Carrasco Maur
    • Mohit Chandra
  • Eder Jorge
    • Mohit Chandra
  • Alain Gauthier
    • Mohit Chandra
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home