[英]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.