我想在Magento的管理區域的「目錄產品」網格中添加一個新列。Magento - 包含自定義輸出/邏輯的AdminHtml產品網格中的自定義列?
新列將被稱爲目前優惠?或銷售項目?,當產品的price
大於special_price
(即產品在銷售中)時,將顯示「是」。
到目前爲止,我已經能夠在special_price
列添加到網格,通過下面的代碼:
$collection->joinAttribute('special_price', 'catalog_product/special_price', 'entity_id', null, 'left', $store->getId());
$this->addColumn('special_price',
array(
'header'=> Mage::helper('catalog')->__('Special Price'),
'type' => 'price',
'currency_code' => $store->getBaseCurrency()->getCode(),
'index' => 'special_price',
));
但我真正需要的是實際執行某種另一列的邏輯來比較special_price,如果打折則打印「是」,否則打印「否」。
我已經添加了列,但就目前而言,很明顯,這是因爲它的index
不對應任何數據真正來源是空的:
$this->addColumn('is_sale_item',
array(
'header'=> Mage::helper('catalog')->__('Sale Item?'),
'type' => 'options',
'index' => 'is_sale_item', // <--- HOW DO I POPULATE THIS INDEX?
'options' => array(0 => 'No', 1 => 'Yes')
));
我將如何實現這一目標?我會在哪裏放置「is_sale_item」計算的邏輯並使其成爲「真實」索引?