0

我以编程方式创建了产品的自定义属性(Setup->Installdata.php)。

 $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'serial_code_use_customer',
            [
                'type' => 'int',
                'backend' => '',
                'frontend' => '',
                'label' => 'Issue By Customer Group',
                'input' => 'boolean',
                'class' => '',
                'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class,
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => true,
                'required' => false,
                'user_defined' => true,
                'default' => '0',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false,
                'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
                'group' => self::GROUP_LABEL,
                'sort_order' => 3,
                'note' => 'Enable automatic issuing of codes based on customer group.'
            ]
        );

        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'serial_code_customer_groups',
            [
                'type' => 'varchar',
                'backend' => '',
                'frontend' => '',
                'label' => 'Select Customer Groups',
                'input' => 'multiselect',
                'class' => '',
                'source' => \Magento\Customer\Model\Customer\Attribute\Source\Group::class,
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => true,
                'required' => false,
                'user_defined' => true,
                'default' => '0',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false,
                'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
                'group' => self::GROUP_LABEL,
                'sort_order' => 4,
                'note' => 'Customers in selected groups will be issued codes automatically when product is ordered.'
            ]
        );

我想在 Adminpanel Magento 2.4.x 的产品详细信息/编辑页面中隐藏或显示基于其他自定义属性的自定义属性?

例如,点击(是/否)会有一个切换,客户组将是 Hide / Show

在此处输入图像描述

4

1 回答 1

0

要从管理产品详细信息页面隐藏自定义产品属性,您需要在 My/Catalog/Setup 目录中创建 UpgradeData.php。代码:

$eavSetup->updateAttribute(Product::ENTITY, $attrCode, 'is_visible', '0');

于 2022-01-04T02:32:13.750 回答