次のコードを使用して、Magento インストールにカスタム カテゴリ属性を追加しました。
<?php
// initialize magento environment for 'default' store
require_once 'app/Mage.php';
Mage::app('default');
echo "initialising";
echo runAdd();
echo "finishing";
function runAdd()
{
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
// below code will add text attribute
$setup->addAttribute('catalog_category', 'test_field', array(
'group' => 'General',
'input' => 'text',
'type' => 'varchar',
'label' => 'a new text field',
'backend' => '',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
}
バックエンドで設定した値を実際に取得するのは非常に困難です。私は次のすべてのバリエーションを試しました:
$_category = Mage::getModel('catalog/category')->load(1000);
$data = $_category->getData();
$atts= $_category->getAttributes();
var_dump($data );
var_dump($atts);
などですが、立ち往生しています。
このデータを取得する方法を知っている人はいますか?