Magento隐藏的自定义产品属性

Magento隐藏的自定义产品属性

本文介绍了Magento隐藏的自定义产品属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am currently making a module so that users see on the checkout page something like: "People who purchased product X also purchased Y, Z and T".

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

I made a cronjob to calculate which are the related products for each product, and I added an attribute to products in the install script.

我决定(为简单起见)-存储最相关的5种产品,因此我想存储以下内容:123-3-5543-1290-9911.但是我不希望管理员在任何地方看到它,我尝试了以下操作:

I decided (for simplicity) - to store the most related 5 products, so I want to store something like: 123-3-5543-1290-9911. But I don't want the administrator to see this anywhere, and I tried the following:

$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/,我发现了一些有趣的内容,但没有找到如何完全隐藏此字段的方法.

I looked here: http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/ and I found some interesting stuff, but not how to completely hide this field.

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

The alternative would be to create my own table, but this seems to be a slightly more elegant solution.

您怎么看?创建我自己的表或添加属性并将其隐藏会更好吗?

What do you think? Is it better to create my own table, or to add an attribute and hide it?

谢谢

推荐答案

将商品目录属性的'is_visible'属性设置为0会将其从后端的管理表单中隐藏,如以下代码所示( Mage_Adminhtml_Block_Widget_Form :: _ setFieldset ()):

Setting the 'is_visible' property to 0 for catalog attributes will hide them from the admin forms in the backend, as can be seen from this code (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');

这篇关于Magento隐藏的自定义产品属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 08:11