【问题标题】:Magento 1.8: While adding new product attribute non of the frontend params are set to yesMagento 1.8:在添加新产品属性时,前端参数中的非设置为 yes
【发布时间】:2014-01-24 12:33:31
【问题描述】:

这是我用来添加新产品属性并将前端设置设置为是的代码:

<?php

$installer = Mage::getResourceModel('catalog/setup','catalog_setup');
$installer->startSetup();

$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, $specCode, array(
        'group' => $profileGroupName,
        'sort_order' => 1,
        'type' => 'varchar',
        'backend' => '',
        'frontend' => '',
        'label' => $specLabel,
        'note' => $specNote,
        'input' => 'text',
        'class' => '',
        'source' => '',
        'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'required' => true,
        'user_defined' => true,
        'default' => '',
        'unique' => false,
        'used_for_promo_rules' => true,
        'searchable'        => true,
        'filterable'        => true,
        'comparable'        => true,
        'visible'      => true,
        'visible_on_front'   => true,
        'visible_in_advanced_search'   => true,
        'is_configurable'   => false
    ));
...

几乎所有的前端设置都设置为 true,但在后端安装它们后,我可以看到此设置设置为 no。

问候,

【问题讨论】:

    标签: magento magento-1.8


    【解决方案1】:

    已修复。在下面工作的代码。只需在这两个类 Mage_Eav_Model_Entity_Setup、Mage_Catalog_Model_Resource_Setup 中保留此方法 _prepareValues 的 $attr 数组键名即可。第二类继承自第一类,因此如果您想添加前端设置,您的安装程序需要是第二类的对象。

    $installer = new Mage_Catalog_Model_Resource_Setup();
    $installer->startSetup();
    
    $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, $tradeCode, array(
            'group' => $profileGroupName,
            'sort_order' => 1,
            'type' => 'varchar',
            'input' => 'text',
            'label' => $tradeLabel,
            'note' => $tradeNote,
            'required' => 1,
            'unique' => 0,
            'user_defined' => 1,
            'default' => '',
            # Additional attribute data - forntend
            'frontend_input_renderer' => '',
            'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
            'visible' => 1,
            'searchable' => 1,
            'filterable' => 1,
            'comparable' => 1,
            'visible_on_front' => 1,
            'wysiwyg_enabled' => 0,
            'is_html_allowed_on_front' => 0,
            'visible_in_advanced_search' => 1,
            'filterable_in_search' => 1,
            'used_in_product_listing' => 1,
            'used_for_sort_by' => 1,
            'apply_to' => '',
            'position' => '',
            'is_configurable' => 0,
            'used_for_promo_rules' => 0,
        ));
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多