首页 文章

Magento隐藏了自定义产品属性

提问于
浏览
2

我目前正在制作一个模块,以便用户在结帐页面上看到类似:“购买产品X的人也购买了Y,Z和T” .

我制作了一个cronjob来计算每个产品的相关产品,并在安装脚本中为产品添加了一个属性 .

我决定(为简单起见) - 存储最相关的5个产品,所以我想存储类似的东西: 123-3-5543-1290-9911 . 但我不希望管理员在任何地方看到这个,我尝试了以下内容:

$setup->addAttribute('catalog_product', $attrCode, array(
    // more stuff
    'type' => 'hidden',
    'input' => 'text',
    'visible' => 0,
    // more stuff
));

我看了一下:http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/我找到了一些有趣的东西,但不知道怎么完全隐藏这个字段 .

另一种方法是创建我自己的表,但这似乎是一个稍微优雅的解决方案 .

你怎么看?创建自己的表,添加属性并隐藏它是否更好?

谢谢

2 回答

  • 6

    我以这种方式解决它 .

    转到 Catalog >> Attributes >> Manage Attributes >> Add new attribute

    然后,保存 . 然后,转到数据库并运行此查询:

    SELECT * FROM eav_attribute WHERE attribute_code ='attribute_code';
    

    将列frontend_input值更改为hidden,然后保存 .

    希望能帮助到你 .

  • 0

    将目录属性的'is_visible'属性设置为0会将它们隐藏在后端的管理表单中,如此代码(Mage_Adminhtml_Block_Widget_Form::_setFieldset())所示:

    protected function _setFieldset($attributes, $fieldset, $exclude=array())
        {
            $this->_addElementTypes($fieldset);
            foreach ($attributes as $attribute) {
                /* @var $attribute Mage_Eav_Model_Entity_Attribute */
                if (!$attribute || ($attribute->hasIsVisible() && !$attribute->getIsVisible())) {
                    continue;
                }
    

    所以执行

    $setup->updateAttribute('catalog_product', $attrCode, 'is_visible', '0');
    

相关问题