Настройка скрипта не работает должным образом

magento.stackexchange https://magento.stackexchange.com/questions/890

  •  16-10-2019
  •  | 
  •  

Вопрос

Мне нужно добавить атрибут через сценарий настройки. Свойства Attribute работают, но свойства Frontend не применяются, как указано в сценарии Setup. Например, visible_on_front is_html_allowed_on_front не работает.

$installer = $this;

$installer->startSetup();

$entityType = 'catalog_product';
$attributeCode= 'video';

$data = array(
    'label' => 'Video',
    'input' => 'textarea',
    'type'  =>  'text',     //database input type
    'visible' => true,
    'required'  =>  false,
    'comparable'=> false,
    'searchable'    => false,
    'filterable'    => false,
    'unique'    => false,
    'visible_on_front'  => true,
    'is_html_allowed_on_front' => true,
    'global'    =>  Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'user_defined' => true,
    'apply_to'  =>  '',
    'is_configurable'   =>  false,
);

$installer->addAttribute($entityType, $attributeCode, $data);

$installer->endSetup();

Часть config.xml

<config>
    <modules>
        <Company_Video>
            <version>0.1.0</version>
        </Company_Video>
    </modules>
    <global>
        <resources>
            <video_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </video_read>
            <video_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </video_write>
            <video_setup>
                <setup>
                    <module>Company_Video</module>
                    <class>Mage_Eav_Model_Entity_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </video_setup>
        </resources>
    </global>
</config>
Это было полезно?

Решение

Я думаю, что установщик не работает правильно, потому что вы используете неправильный класс настройки.

В вашем config.xml попробуйте поместить следующее:

<video_setup>
    <setup>
       <module>Company_Video</module>
        <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
    </setup>
    <connection>
       <use>core_setup</use>
    </connection>
</video_setup>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top