Jump to content

Recommended Posts

I've been successful in creating an extra table in the prestashop products table throught rest api of webservice , however the api link http://127.0.0.1/prestashop/api/wb3d/1 wb3d is the new table which i have created in webservice . which holds a path to images directory somewhere on the web . this link when opened shows the data which has been saved in the database.. in the following image below 
 
post-999539-0-93599900-1430470755_thumb.png
 
model is directory name on the web,so this api(wb3d) has been associated with the   product table  in the webservice the link:http://127.0.0.1/prestashop/api/products/1 when i open this link . then entry of the association is shown but the data is not shown refer the below image
 
 
post-999539-0-10627500-1430470935_thumb.png
 
 
the highlighted area shows the wb3d table associated with the product table through rest api of webservice . i.m unable to associate the wb3d table data with product table data. so i can use it in other devices through webservice i cant figure out what i,m missing here.. if anyone has achieved this . put some insights on this .

 

 

this is what i have tried till now 

 <?php
    class ProductMergeCore extends ObjectModel
 
    {  
        public $product_id;
        public $id_wb3d;
        public $directory_name;
        public static $definition = array(
        'table' => 'wb3d',
        'primary' => 'id_wb3d',
        'fields' => array(
        'id_wb3d' => array('type' => self::TYPE_INT,  'required' => true),
        'product_id' => array('type' => self::TYPE_INT, 'required' => true),
        'directory_name' => array('type' => self::TYPE_STRING,  'required' =>false, 'size' => 64),
         ),
         );
        protected $webserviceParameters = array();
        }
        ?>

ProductMerge.php is responsible for creating an associate table entry in product table

 <?php 

      Class Product extends ProductCore

      {
  
       public $extrafield;

 

    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)

     {


        $this->webserviceParameters['associations']['wb3d'] = array('resource'    => 'wb3d','fields' => array('directory_name' => array('required' => true)));

        parent::__construct($id_product, $full, $id_lang, $id_shop, $context);

     }

    }
    ?>
  in this  product.php  which is for overriding the product class for passing the extra parameters through       webserviceparameters() and then calling the parent constructor of the product class
 
 
<?php
    class WebserviceRequest extends WebserviceRequestCore
    {
    public static function getResources()
    {
    $resources=parent::getResources();
    $resources['wb3d'] = array('description' => 'images path', 'class' =>   'ProductMerge');
    ksort($resources);
    return $resources;
    }
    }
    ?>

WebserviceRequest.php class is a override class for the WebserviceRequest class which shows the description of the table entry in the webservice

 

These are the files which are required to get the things done. what i,m trying to achieve is the associated table (wb3d) data should be available within products table through webservice rest api call. anyone who is familiar with this can give there thoughts.

 
 
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...