kornett Posted April 18, 2014 Share Posted April 18, 2014 (edited) When I create a new shop using the webservice and a new employee using the webservice, both are assigned correctly and in the database table ps_employee_shop and the new employee is only assigned to his current shop: i.e. id_employee id_shop 1 1 1 2 2 2 So in the above example id_employee 1 is the admin, and 2 is the new employee created, so as you can see it looks fine, he only has access to his shop. The problem is that whenever that employee logins to the admin panel, there is something (probably a hook) that gives the employee access to the main store, inserting the new record. So now the table looks like this: id_employee id_shop 1 1 1 2 2 2 2 1 I don't understand why it gives users access to the main shop, even if the user is created with a low permissions profile. What is the hook or file that is inserting this record? Is there a way to disable this in the admin panel? Any input will be appreciated! Thanks, By the way I'm using the latest PS version 1.6.0.6 Edited April 18, 2014 by kornett (see edit history) Link to comment Share on other sites More sharing options...
kornett Posted April 23, 2014 Author Share Posted April 23, 2014 I found that the issue was caused because I was sending some empty values in the employee webservice because they were not "required", ... makes no sense, but that fixed it for me. Link to comment Share on other sites More sharing options...
Wazzu Posted August 26, 2014 Share Posted August 26, 2014 Thanks for sharing your solution. Do you kno which empty field was making this issue? Link to comment Share on other sites More sharing options...
daed Posted September 8, 2014 Share Posted September 8, 2014 Hi please how you create a new employee using the webservice ? can ou give me the code please Link to comment Share on other sites More sharing options...
Wazzu Posted September 8, 2014 Share Posted September 8, 2014 Hi please how you create a new employee using the webservice ? can ou give me the code please You can use the API 'employees' method: http://doc.prestashop.com/display/PS16/Web+service+reference Question is: How do you assign that employee to the correct shop? Link to comment Share on other sites More sharing options...
daed Posted September 8, 2014 Share Posted September 8, 2014 (edited) You can use the API 'employees' method: http://doc.prestashop.com/display/PS16/Web+service+reference Question is: How do you assign that employee to the correct shop? thanks Wazzu for the reply When I create a new employee using the webservice, the new employee is only assigned to his main shop: i.e. table ps_employee_shop and id_employee id_shop 1 1 2 1 3 1 So i have the same question now: How i can assign the new employer to the correct shop? Edited September 9, 2014 by daed (see edit history) Link to comment Share on other sites More sharing options...
Wazzu Posted September 8, 2014 Share Posted September 8, 2014 Well, I never got an answer as it's not implemented (what a shame) So I extended web services and created a new method for dealing with ps_employee_shop table First I created a /classes/EmployeeShop.php file based on some othe class file in that directory, something like this: 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'), ), ); } Then I added the new method inside /classes/webservice/WebserviceRequest.php (line 299 in my example): 'employees' => array('description' => 'The Employees', 'class' => 'Employee'), 'employee_shop' => array('description' => 'Employees Shop assignation', 'class' => 'EmployeeShop'), 'search' => array('description' => 'Search', 'specific_management' => true, 'forbidden_method' => array('PUT', 'POST', 'DELETE')), And that's how I'm making it, still WIP and of course no update-safe :-( And there's more: even if you manage to create a multishop and an employee, you will face many other problems later, all of them related with multistore feature (categories, products, etc). It seems prestashop web service isn't aware of multistore functionality at all :-( 1 Link to comment Share on other sites More sharing options...
daed Posted September 9, 2014 Share Posted September 9, 2014 (edited) Thanks wazzu for sharing your solution I created "EmployeeShop.php" Then I added the new method inside /classes/webservice/WebserviceRequest.php but in the store's webservice (mystore/api), "employee_shop" is not displaed like customers, categories,employees . . . so please what is wrong ?? Edited September 9, 2014 by daed (see edit history) Link to comment Share on other sites More sharing options...
daed Posted September 9, 2014 Share Posted September 9, 2014 (edited) Hi wazzu, it is solved but without any modification in prestashop code we can assign the new employer to the correct shop as follow: creating webservice access: $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); here the PS_SHOP_PATH is the path of the desired shop and not the main shop and in order to use the same PS_WS_AUTH_KEY of the main shop you shoud chek all the store in shop association (backoffice :Advanced Parameters-->Webservice) Edited September 9, 2014 by daed (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts