[英]Magento filter products in Grid page on collection load
我想过滤产品网格中的产品集合,
我的要求是,我正在创建模块,供供应商访问类别产品。
他将只能看到具有特定供应商代码的产品。
我为产品添加了新属性,
并在Grid.php文件中编写以下代码。 但是没有用。 请帮忙。
$ vendor =法师:: getSingleton('admin / session')-> getUser()-> getData('username');
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('sku')
->addAttributeToSelect('name')
->addAttributeToSelect('attribute_set_id')
->addAttributeToSelect('type_id')
->addAttributeToSelect('vendor')
->addAttributeToFilter(array('attribute'=>'vendor','eq'=> $vendor));
尝试这个
$collection->addFieldToFilter('vendor',$vendor);
在此处阅读更多信息http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-8-varien-data-collections
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.