実行して、Magentoのルートディレクトリにこのスクリプトを実行します。(環境設定の変更必要)
<?php
require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$installer->addAttribute('catalog_product', 'snum', array(
'label' => 'Serial No',
'type' => 'int',
'input' => 'text',
'backend' => '',
'frontend' => '',
'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' => true,
'visible_in_advanced_search' => false,
'unique' => false
));
$installer->endSetup();
?>
あなたはshown.IfとしてMagentoのバックエンドにカスタム属性を追加することができます製品属性をモジュールとして作成し、あるデータベースから別のデータベースに移動するのは簡単です。
?php
$this->startSetup();
$this->addAttribute(catalog_product, 'featured_product', array(
'group' => 'General',
'input' => 'select',
'type' => 'text',
'label' => 'Featured Product',
'backend' => '',
'visible' => true,
'required' => false,
'visible_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'source' => 'eav/entity_attribute_source_boolean',
'sort_order' => 8,
));
$this->endSetup();
ステップの説明とファイル構造によってステップのための私のチュートリアルを参照してください。 http://www.pearlbells.co.uk/adding-custom-product-attributes-in-magento/
addattributeコマンドで$ attrCodeを忘れてしまったようです。 – Benubird
@Benubird - それを指摘してくれてありがとう! –
@KnowledgeCraving - 新しいMage_Catalog_Model_Resource_Eav_Mysql4_Setup()の代わりに、Magentoのファクトリシステム(とそのための書き換え可能性)を尊重するために、 'Mage :: getResourceModel( 'catalog/setup'、 'core_setup')'を使用する方がよい。 – 7ochem