【发布时间】:2023-03-09 07:45:01
【问题描述】:
我为产品“sellable_in_market”创建了一个自定义属性。并尝试在产品网格中显示它。但那一栏是空的。但是如果我用 YES/NO 过滤,那么它就会显示出来。如何在网格中显示不带过滤器的属性值(“sellable_in_market”)?不知道该怎么做。以下是我的代码。
提前致谢。
protected function _prepareCollection()
{
parent::_prepareCollection();
$collection = $this->getCollection();
$store = $this->_getStore();
if ($store->getId()) {
$collection = $collection->joinAttribute(
'sellable_in_market',
'catalog_product/sellable_in_market',
'entity_id',
null,
'left',
$store->getId()
);
}
else {
$collection = $collection->joinAttribute('sellable_in_market', 'catalog_product/sellable_in_market', 'entity_id', null, 'left');
}
$this->setCollection($collection);
return $this;
}
protected function _prepareColumns()
{
$this->addColumnAfter('sellable_in_market',
array(
'header'=> Mage::helper('catalog')->__('Resellable'),
'width' => '60px',
'index' => 'sellable_in_market',
'sortable' => true,
'type' => 'options',
'options' => array("1" => 'Yes', "0" => 'No'),
),
'type'
);
parent::_prepareColumns();
}
在网格中的“Resellable”列是空的。但是如果我们用是/否过滤,那么它就会显示出来。 如何在网格中默认显示自定义值?
【问题讨论】:
-
您是否在产品列表页面中打印了产品数组?
-
是的,没问题。我可以在那里看到“sellable_in_market”。
-
您在管理网格上的收藏中获得了价值吗?
-
我正在获取集合中的值而不是网格中的值。