インストールスクリプトを介して属性のデフォルト値を設定する方法は?
-
16-10-2019 - |
質問
カスタムモジュールのインストールスクリプトを使用して属性を作成しました。 1つの属性は、「はい」、「いいえ」などの2つのオプションしかないドロップダウンです。もう1つの属性はテキストフィールドです。このスクリプトでデフォルト値を設定する必要があります。次のことを結びました。しかし、うまくいきませんでした。
$th = new Mage_Catalog_Model_Resource_Setup();
$th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'credit', array(
'group' => 'Prices',
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'Credit rewards',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 'kkkkkkkk', // this is default value. but is's not setting
'searchable' => false,
'filterable' => true,
'comparable' => false,
'visible_on_front' => true,
'visible_in_advanced_search' => true,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => 'simple',
) );
どんな提案にも感謝します。 Advancedに感謝します。
解決
/**
* @var $th Mage_Eav_Model_Entity_Setup
*/
$th =new Mage_Eav_Model_Entity_Setup('core_setup');
$th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'credit', array(
'group' => 'Prices',
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'Credit rewards',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 'kkkkkkkk', // this is default value.
'searchable' => false,
'filterable' => true,
'comparable' => false,
'visible_on_front' => true,
'visible_in_advanced_search' => true,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => 'simple',
));
他のヒント
/**
* @var $th Mage_Eav_Model_Entity_Setup
*/
$th =new Mage_Eav_Model_Entity_Setup('core_setup');
$th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'credit', array(
'group' => 'Prices',
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'Credit rewards',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 'kkkkkkkk', // this is default value.
'searchable' => false,
'filterable' => true,
'comparable' => false,
'visible_on_front' => true,
'visible_in_advanced_search' => true,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => 'simple',
));
所属していません magento.stackexchange