1

想要对产品名称进行过滤,如状态已完成。(产品 [Samsung,alien] 这些值是从数据库中随机显示的,我不知道它的代码写在哪里以及它在哪个逻辑上呈现)。请按步骤提供答案。

提前致谢。

4

2 回答 2

1

我收到了解决方案。刚刚用我的数据库字段名称添加了索引数据(location:/var/www/magento/app/code/local/One/First/Block/Adminhtml/First/Grid.p‌​‌​hp)
----------->
$this->addColumn('select_first',array( 'header' => Mage::helper('first')->__('Product Name'), 'width' => '150px', 'index' => 'proid', 'type' => 'options', 'options' => Mage::getSingleton('first/arrayf')->getProArray(), ));

于 2012-12-03T08:04:10.277 回答
0
 $collection = Mage::getModel('catalog/product')->getCollection()
        ->addAttributeToSelect('sku')
        ->addAttributeToSelect('name')
        ->addAttributeToSelect('attribute_set_id')
        ->addAttributeToSelect('type_id')
        ->joinField('qty',
            'cataloginventory/stock_item',
            'qty',
            'product_id=entity_id',
            '{{table}}.stock_id=1',
            'left')
        ->joinAttribute('status', 'catalog_product/status',
                        'entity_id', null, 'inner', $store->getId());

现在您在 $collection 上拥有所有产品和各自的状态,您可以通过以下方式进行过滤:

$collection->addAttributeToFilter('status', array(
'like' => array('status'),
));
于 2012-10-08T12:08:20.073 回答