Jump to content

can i restrict access for an emplyoee to only one categorie


dj sunny omkar

Recommended Posts

i have many employees in my organizations i want one employee to take care of one categories alone without disturbing other categories or viewing other categories.
I could achive this by creating a profile and enabling the view permit for catalog ..
But i want to restrict an employee for a particular categorie alone how do i achive this please help ??

  • Like 1
Link to comment
Share on other sites

I don't think you can do this without code modification, because the profile control is at catalog level.

I you would like to do that, you can look into following file inside __construct, add some control after following lines.

       $this->_category = AdminCatalog::getCurrentCategory();

Link to comment
Share on other sites

  • 2 weeks later...

after this line

$this->_category = AdminCatalog::getCurrentCategory(); 



add this two lines

global $cookie;
if($this->_category->id != X AND $cookie->id_employee != Y)die("you don't have permission");



where X is the category ID that allow the employee to access
Y is there ID of employee

By the way, I have multiple seller module, that handle much more permission scenarios.
It allow customer to become a seller of your store. You can also register other seller at back office.
All seller can only access their own products, customer and order.
There are a lot of more features if you in interested, you can have a look at this thread
http://www.prestashop.com/forums/viewthread/104232/

Link to comment
Share on other sites

  • 2 months later...

I read the features of the module. Very interesting, I'll take shortly.

Let me know if it is possible to do this:

A category is shared between multiple vendors, but each seller can edit only products added by him.

Link to comment
Share on other sites

I read the features of the module. Very interesting, I'll take shortly.

Let me know if it is possible to do this:

A category is shared between multiple vendors, but each seller can edit only products added by him.

Yes, you can do this. Any category created by Admin is shared by all sellers and vendors. Thanks for your question.

Link to comment
Share on other sites

I read the features of the module. Very interesting, I'll take shortly.

Let me know if it is possible to do this:

A category is shared between multiple vendors, but each seller can edit only products added by him.

Yes, you can do this. Any category created by Admin is shared by all sellers and vendors. Thanks for your question.

 

Thanks for the reply.

I understand that the categories are shared,

but the seller can only edit the articles entered by him in that category or all the articles?

Link to comment
Share on other sites

  • 5 months later...

Please help, i am not able to restrict the permissions at Category level for employees by using the code given above....

I am using 1.5 version of prestashop.

 

i edit the file AdminCmscontroller.php.(am i editing the right file?)

 

added the code like...

 

 

$this->_category = AdminCmsContentController::getCurrentCMSCategory();

 

global $cookie;

if($this->_category->id != 2 AND $cookie->id_employee != 2)die("you don't have permission"); (added this line)

if($this->_category->id != 3 AND $cookie->id_employee != 3)die("you don't have permission"); (added this line)

 

$this->_join = '

LEFT JOIN `'._DB_PREFIX_.'cms_category` c ON (c.`id_cms_category` = a.`id_cms_category`)';

$this->_select = 'a.position ';

$this->_filter = 'AND c.id_cms_category = '.(int)($this->_category->id);

Link to comment
Share on other sites

  • 2 years later...

it can be easily achieved by this

 

add a filed in employee table supplier_id , 

 

Link employee table and supplier table through this filed, insert supplier_id in employee table

 

then create a employee profile with only catalog privileges

 

change the code in "AdminProductsController" in where clause add supplier_id , [session supplier id]  

 

this will show the products of that employee linked with the supplier id

 

 

can anyone please tell me where to set the cookie for new employee table filed "supplier_id" 

Edited by rajlaskar (see edit history)
Link to comment
Share on other sites

  • 11 months later...

after this line

 

$this->_category = AdminCatalog::getCurrentCategory();

add this two lines

 

global $cookie;if($this->_category->id != X AND $cookie->id_employee != Y)die("you don't have permission");

where X is the category ID that allow the employee to access

Y is there ID of employee

 

By the way, I have multiple seller module, that handle much more permission scenarios.

It allow customer to become a seller of your store. You can also register other seller at back office.

All seller can only access their own products, customer and order.

There are a lot of more features if you in interested, you can have a look at this thread

http://www.prestashop.com/forums/viewthread/104232/

 

Dear All it  is possible to implement in presta 1.6? . i need also block some categories for some employe's. 

 

in presta 1.6 i canot find tlis line ....

 

thx

 

Arek

Link to comment
Share on other sites

When i add this line global $cookie;if($this->_category->id != X AND $cookie->id_employee != Y)die("you don't have permission");

 

in to AdminProductsController.php and then i go to BO and when i click add produck i have info "you dont have permition" this should block category.... how can i block some categotiy in presta 1.6?

 

Arek

Link to comment
Share on other sites

I guess you want to this at back office catalogue, 

to block an employee from access category, you need add related code in following file

/controllers/admin/AdminCategories.php

 

Yes i want to block in backoffice, 

 

in presta 1.6 i can only find file : AdminCategoriesController.php , could You advice me after which line i need to past this code? :

 

lobal $cookie;if($this->_category->id != X AND $cookie->id_employee != Y)die("you don't have permission");

 

thx

Arek

Link to comment
Share on other sites

sorry, it is AdminCategoriesController.php instead of AdminCategories.php, I modified the post.

you can try to add the code after this line

public function init(){
parent::init();


// context->shop is set in the init() function, so we move the _category instanciation after that
if (($id_category = Tools::getvalue('id_category')) && $this->action != 'select_delete')
$this->_category = new Category($id_category);
else
{
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)
$this->_category = new Category($this->context->shop->id_category);
elseif (count(Category::getCategoriesWithoutParent()) > 1 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) != 1)
$this->_category = Category::getTopCategory();
else
$this->_category = new Category(Configuration::get('PS_HOME_CATEGORY'));
}


Link to comment
Share on other sites

 

sorry, it is AdminCategoriesController.php instead of AdminCategories.php, I modified the post.

you can try to add the code after this line

public function init(){
parent::init();


// context->shop is set in the init() function, so we move the _category instanciation after that
if (($id_category = Tools::getvalue('id_category')) && $this->action != 'select_delete')
$this->_category = new Category($id_category);
else
{
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)
$this->_category = new Category($this->context->shop->id_category);
elseif (count(Category::getCategoriesWithoutParent()) > 1 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) != 1)
$this->_category = Category::getTopCategory();
else
$this->_category = new Category(Configuration::get('PS_HOME_CATEGORY'));
}


i just add  this one line after your code: if ($this->_category->id != 4 AND $cookie->id_employee != 1)die("you don't have permission");

 

and when i click on category on BO i see only "you dont have parmition" ,  but i should see it when i try to click on sub category with ID 4.

what im doing wrong?

 

also i just try with this 2 lines:  

 

global $cookie;

if ($this->_category->id != 4 AND $cookie->id_employee != 1)die("you don't have permission");

 

now i have access to BO / categoty but cat with id4 still exist.

 

basicly also not working

Edited by stuka (see edit history)
Link to comment
Share on other sites

After tests this is working line: if ($this->_category->id != 2 AND $cookie->id_employee != 2)die("you don't have permission");

 

_category->id != 2 - it is main category , but when i click on next subdirectory i have info you dont have permiission, 

 

i also try to add more lines example: 

 if ($this->_category->id != 2 AND $cookie->id_employee != 2)die("you don't have permission");

 if ($this->_category->id != 3 AND $cookie->id_employee != 2)die("you don't have permission");

 if ($this->_category->id != 4 AND $cookie->id_employee != 2)die("you don't have permission");

 

but without success, how can i solve this?

Link to comment
Share on other sites

Also i have a question, it is possible to connecto only one or 2 categories in tree category to one emplotte? like on  my picture:

 

example : Employee ID: 2 should have onny acceess his category T-shirts.

 

 

 

tree.png?_subject_uid=33996645&w=AABlwsw

Link to comment
Share on other sites

  • 1 year later...

Good day.

The information above is very usefull, but little bit not actual. 

Who can tell, how to restrict for employees showing orders with specific "id_current_state" or "current_state" on the "Orders" page (where is located list of orders, not just 1 order).

For example, do not display orders with status "Delivered".

I found that presta using this table in next files:  

 

classes/controller/AdminController.php:3221

/classes/order/OrderState.php:129

/Adapter/Adapter_EntityMapper.php:68

 

But it's little bit not exactly what I need, probably I need to edit tpl file, but there is no any info in debug mode about used tpl files on current page.

 

I have 2 ways - but dont have clear idea what to do:

Way #1 in orderState.php - Edit php file (I tried to get global employee_id and if (employee_id != 1 && id_order_state == 11) just to do not write such raw into $result variable. Probably it's a wrong way, at least after such changes my orders page didnt work :)

 

Way #2 - find tpl file and in the same way do not display such orders, with special status. (probably it must work like existing filter, but I also can't find filter's logic)

 

Maybe somebody faced already with such problem, or knows where to found needed tpl files. 

Thank you!

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