magento user can see his product only

2019-08-06 12:22发布

问题:

I am new in magento. I have created user role merchant as well as create user named stockuser1. Now he can see product added by admin too. How should I restrict him that he can see product added by him only?
Thanks in advance.

回答1:

A simple way to achieve this is, by creating an attribute suppose product_user and define all the users in it, then assign this attribute to your functional attribute set. you have to assign each product a user, then copy the app\code\core\Mage\Adminhtml\Block\Catalog\Product\Grid.php to local folder as app\code\local\Mage\Adminhtml\Block\Catalog\Product\Grid.php add the following lines:

$admin = Mage::getSingleton('admin/session')->getUser();
if($admin->getUsername() !='your actual admin'){
     $collection->addAttributeToFilter('product_user', $admin->getUsername());
}

under the function _prepareCollection()

Hope this will work but I haven't tested.



标签: magento