Jump to content

[API] Assign employee to shop


Recommended Posts

Hi all.


I've been able to create a new shop in a multistore shop using webservices.

After creating a shop, I asign an URL to that shop.

Finally, I create a new employee and everithing is fine, no errors, all objects are created.


Problem is that new newly create employee has access to the main store, not the new multishop I've just created.


Question is:

how can I make it from webservices so I can assign an employee to a specific multistore?

Is it even possible?


Thanks in advance. Best regards.

Link to comment
Share on other sites

  • 1 month later...
Hi, shoofra 
Unluckly I got no way of doing it so I had to create a new class for the api to manage this
First I expanded webservices by creating override\classes\webservice/WebserviceRequest.php
class WebserviceRequest extends WebserviceRequestCore {

	public static function getResources() {
		$resources['employee_shop'] = array('description' => 'Employees Shop assignation', 'class' => 'EmployeeShop');
		return $resources;


Then I created a override/classes/EmployeeShop.php file

class EmployeeShopCore extends ObjectModel
	/** @var int Determine employee id */
	public $id_employee;

	/** @var int Determine shop id */
	public $id_shop;

	 * @see ObjectModel::$definition
	public static $definition = array(
		'table' => 'employee_shop',
		'primary' => 'id_employee',
		'fields' => array(
			'id_employee' => array('type' => self::TYPE_INT, 'required' => true),
			'id_shop' =>     array('type' => self::TYPE_INT, 'required' => true),

	protected $webserviceParameters = array(
		'fields' => array(
			'id_employee' => array('xlink_resource' => 'employees'),
			'id_shop' => array('xlink_resource' => 'shops'),
	public function add($autodate = true, $null_values = false) {
		$result = parent::add($autodate, $null_values);

Finally I ended up by another way, so these code snippets are a work-in-progress, maybe not fully funcitonals

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