我正在嘗試爲Magento 1.8.x運行安裝程序腳本,但我不確定如何執行它。任何人都可以確認是否有任何問題與我的文件下面,也如何讓Magento實際執行此腳本並添加此自定義客戶屬性?無法在Magento中運行安裝程序腳本(1.8.x)
這裏是我的文件夾結構(包括剛纔那些我覺得適用於此):
\app\code\local\SS\Rapt\
\app\code\local\SS\Rapt\etc\config.xml
\app\code\local\SS\Rapt\sql\mysql4-install-0.0.1.php
我的安裝文件如下:
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('customer', 'organisation_id', array(
'input' => 'select', //or select or whatever you like
'type' => 'int', //or varchar or anything you want it
'label' => 'Organisation ID',
'visible' => 1,
'required' => 0, //mandatory? then 1
'user_defined' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'organisation_id',
'100'
);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'organisation_id');
$oAttribute->setData('used_in_forms', array('adminhtml_customer'));
$oAttribute->save();
$setup->endSetup();
我config.xml中如下:
<config>
<modules>
<SS_Rapt>
<version>0.0.1</version>
</SS_Rapt>
</modules>
/** more here but left out as not applicable to this installer feature **/
感謝JS - 會給它一個鏡頭:) 我需要做什麼特別的「執行」這一次代碼已添加? – Zabs
只需重新加載您的Magento商店的任何頁面。 –
我已經這樣做了 - 沒有錯誤(或者我可以看到) - 我怎麼能確定這確實已經執行?例如,這個新的自定義屬性'organisation_id'位於數據庫結構中? – Zabs