Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
magento:将attibute添加到产品,但在编辑产品时不显示_Magento_Attributes_Magento 1.4_Product - Fatal编程技术网

magento:将attibute添加到产品,但在编辑产品时不显示

magento:将attibute添加到产品,但在编辑产品时不显示,magento,attributes,magento-1.4,product,Magento,Attributes,Magento 1.4,Product,根据bens的评论和回答,我更新了我的脚本,评论表示更改 {Magento 1.4.0.1}目前我有一个安装程序脚本: $installer = $this; $installer->startSetup(); //commented out to use factory method //$setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup'); $setup = Mage::getResourceM

根据bens的评论和回答,我更新了我的脚本,评论表示更改

{Magento 1.4.0.1}目前我有一个安装程序脚本:

$installer = $this;
$installer->startSetup();

//commented out to use factory method
//$setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
$setup = Mage::getResourceModel('catalog/setup','core_setup');    

if(!$setup->getAttribute('catalog_product','attribute_code')){
    $newFields = array(
        'attribute_code' => array(
            'type'              => 'text',
            'label'             => 'Attribute Label',
            //added visible option
            'visible'           => false,
        ),
    );

    $entities = array(
        'catalog_product',
    );

    foreach($newFields as $attributeName => $attributeDefs) {
        foreach ($entities as $entity) {
            $setup->addAttribute($entity, $attributeName, array(
                'type'                          => $attributeDefs['type'],
                'label'                         => $attributeDefs['label'],
                //added visible option
                'visible'                       => $attributeDefs['visible'],
                'class'                         => '',
                'required'                      => false,
            ));
        }
    }
}

$installer->endSetup();
它工作得很好!除了在编辑产品时,属性显示在“常规属性”组中,而且我根本不希望它显示(它是一个秘密忍者属性)之外,我有什么做错了吗?或者我应该做些什么让Magento知道它不应该显示?

使用
addAttribute()
可以将“可见
索引”设置为
false
。使用
updateAttribute()`您应该执行以下操作:

$setup->updateAttribute('catalog_product','attr_code','is_visible',false);

如果我错了,请告诉我。

您的代码应该使用工厂方法,即$setup=Mage::getResourceModel('catalog/setup','default_setup');注意。。。那么我的问题呢。。。。。。。有点尴尬事实上我在你发布前5秒在代码中找到了答案。。。我已经找了一个多小时了。。。。哦,老兄,为什么会这样。。。谢谢你的帮助!这在Magento身上并不少见。你可能想参加Magento U课程()或看我免费教授()