2013-03-07 28 views
8

Podążam za tym samouczkiem: http://www.atwix.com/magento/add-category-attribute/ Wszystko działa poprawnie, atrybuty są dodawane do kategorii, ale bez przycisku WYSIWYG poniżej pola. WYSIWYG jest włączone w System> Config> Content Management.Dodaj atrybut kategorii z włączonym WYSIWYG

$this->startSetup(); 
$this->addAttribute('catalog_category', 'custom_att', array(
    'group'   => 'General', 
    'input'   => 'textarea', 
    'type'   => 'text', 
    'label'   => 'My attribute', 
    'backend'  => '', 
    'visible'  => true, 
    'required'  => false, 
    'wysiwyg_enabled' => true, 
    'visible_on_front' => true, 
    'is_html_allowed_on_front' => true, 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
)); 
$this->endSetup(); 

Niezależnie od tego, co próbuję, funkcja WYSIWYG nie jest włączona dla moich atrybutów. Czy ktoś może pomóc? A może istnieje obejście tego problemu?

EDIT: Szukałem innych stanowisk, ale wszyscy mówią, że ten kod powinien dodać WYSIWYG:

'wysiwyg_enabled' => true, 

ale tak nie jest.

+0

Upewnij się, że '$ this' jest instancją' Mage_Catalog_Model_Resource_Setup', a nie 'Mage_Eav_Model_Entity_Setup'. –

Odpowiedz

9

Próbowano wykonać to samo zadanie dzisiaj i przeszukiwania kodu Magento udało się wypełnić moje zadanie z tym kodem:

$productEntityTypeId = $installer->getEntityTypeId('catalog_product'); 
$installer->addAttribute($productEntityTypeId, 'some_text', array(
    'group'   => 'General', 
    'input'   => 'textarea', 
    'type'   => 'text', 
    'label'   => 'Some Text', 
    'backend'  => '', 
    'visible'  => true, 
    'required'  => false, 
    'visible_on_front' => true, 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
)); 
$installer->updateAttribute($productEntityTypeId, 'some_text', 'is_wysiwyg_enabled', 1); 
$installer->updateAttribute($productEntityTypeId, 'some_text', 'is_html_allowed_on_front', 1); 
6

działa następująco:

$installer->updateAttribute('catalog_category', 'certifications', 'is_wysiwyg_enabled', 1); 
$installer->updateAttribute('catalog_category', 'certifications', 'is_html_allowed_on_front', 1); 
+0

Czy możesz zapewnić trochę więcej wsparcia dla swojej odpowiedzi? Dlaczego to działa? – pjmorse

5

ten pracował dla mnie:

$installer->addAttribute('catalog_category', 'short_description', array(
    'type' => 'varchar', 
    'label' => 'Short Description', 
    'input' => 'textarea', 
    'default' => '', 
    'sort_order' => 1, 
    'required' => false, 
    'wysiwyg_enabled' => true, 
    'visible_on_front' => true, 
    'is_html_allowed_on_front' => true, 
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 
    'group' => 'General Information', 
)); 

Należy zwrócić uwagę na następujące trzy wpisy:

'wysiwyg_enabled' => true, 
    'visible_on_front' => true, 
    'is_html_allowed_on_front' => true, 

Korzystanie z Magento CE 1.9.2.0.

+0

To działało dla mnie, ale zauważyłem, że "typ" => "tekst" jest dla mnie bardziej przydatny, ponieważ varchar ma limit 255 znaków. – jmargolisvt

+0

Musiałem użyć '' 'is_wysiwyg_enabled''' do pracy – greatwitenorth

1

Tworzenie pliku php w Magento katalogu i wklej poniższy kod i uruchomić go z poziomu przeglądarki: -

ini_set('display_errors',0); 
require_once 'app/Mage.php'; 
Mage::app(); 

$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); 


function createNewAttributeSet($name) { 
    Mage::app('default'); 
    $modelSet = Mage::getModel('eav/entity_attribute_set') 
    ->setEntityTypeId(4) // 4 == "catalog/product" 
    ->setAttributeSetName($name); 
    $modelSet->save(); 
    $modelSet->initFromSkeleton(4)->save(); // same thing 
} 

// Replace your attribute name with "extra_info" 

$setup->addAttribute('catalog_category', 'extra_info', array(
     'group'    => 'General Information', 
     'type'    => 'text', 
     'backend'   => '', 
     'frontend'   => '', 
     'label'    => 'Extra Information', 
     'wysiwyg_enabled' => true, 
     'visible_on_front' => true, 
     'is_html_allowed_on_front' => true, 
     'input'    => 'textarea', 
     'class'    => '', 
     'source'   => 'eav/entity_attribute_source_boolean', 
     'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 
     'visible'   => 1, 
     'required'   => 0, 
     'user_defined'  => 0, 
     'default'   => '', 
     'searchable'  => 0, 
     'filterable'  => 0, 
     'comparable'  => 0, 
     'visible_on_front' => 0, 
     'unique'   => 0, 
     'position'   => 1, 
)); 
$setup->updateAttribute('catalog_category', 'extra_info', 'is_wysiwyg_enabled', 1); 
$setup->updateAttribute('catalog_category', 'extra_info', 'is_html_allowed_on_front', 1); 
+0

człowiek jesteś niesamowity :) Dzięki –

+0

Jesteś zadowolony :) –