0
我已經安裝了新的產品屬性在Magento(使用幫助)新安裝的產品屬性 - mysql4安裝-1.0.0.php:使用我的模塊腳本怎麼弄的類別頁面
<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
//Setup Product Attribute
$setup->addAttribute('catalog_product', 'product_display_price', array(
'group' => 'Prices',
'label' => 'Webdevelop Extensions - Display Price',
'type' => 'int',
'input' => 'select',
'backend' => '',
'frontend' => '',
'source' => 'eav/entity_attribute_source_boolean',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'visible_in_advanced_search' => false,
'unique' => false,
));
$installer->endSetup();
此屬性( 'product_display_price')我可以採用產品頁面(在我的重寫塊上使用var_dump(getProductAttributeValueDisplayPrice())),但是當我將它放在類別頁面上時,我會得到空值。 我使用的輔助文件(Data.php):
public function getProductAttributeValueDisplayPrice()
{
$currentProduct = Mage::registry('current_product');
if ($currentProduct) {
$product_id = $currentProduct->getId();
$product = Mage::getModel('catalog/product')
->load($product_id);
$attribute = $product->getData('product_display_price');
return $attribute;
}else null;
}