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.