【问题标题】:Magento filter products in Grid page on collection loadMagento 在收集负载的网格页面中过滤产品
【发布时间】:2014-05-24 21:29:39
【问题描述】:

我想过滤产品网格中的产品集合,

我的要求是,我正在创建供应商可以访问类别产品的模块。

他只能看到特定供应商代码的产品。

我为产品添加了新属性,

并在 Grid.php 文件中编写以下代码。但不工作。请帮忙。

$vendor = Mage::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));

【问题讨论】:

  • 集合的输出是什么?

标签: php magento


【解决方案1】:

试试这个

$collection->addFieldToFilter('vendor',$vendor);

在此处阅读更多信息http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-8-varien-data-collections

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多