1

I have create custom attribute programatically, these are the fields,

  $eavSetup->addAttribute(

        \Magento\Catalog\Model\Product::ENTITY,
        'myattribute',/* Custom Attribute Code */
        [
            'group' => 'Product Details',/* Group name in which you want to display your custom attribute */
            'type' => 'text',/* Data type in which formate your value save in database*/
            'attribute_set' =>  'myattribute',
            'backend' => '',
            'frontend' => '',
            'label' => 'Address', /* lablel of your attribute*/
            'input' => 'textarea',
            'class' => '',
            'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
            'visible' => true,
            'required' => false,
            'user_defined' => true,
            'default' => '',
            'searchable' => true,
            'filterable' => true,
            'comparable' => false,
            'visible_on_front' => true,
            'used_in_product_listing' => true,
            'unique' => false
        ]
    );

I need to enable Advanced Search while creating Custom Attribute in programatically, if i set 'searchable' => true' only enable Use in Search field, but not enable Visible in Advanced search.

Reference:

enter image description here

Suggest me How to enable this programatically.

2 Answers 2

3

below line do the trick of enable Visible in Advanced search

'visible_in_advanced_search' => true,
1
  • 1
    Magento is crap buddy, column name in table is 'is_visible_in_advanced_search' and when you create attribute you need to pass 'visible_in_advanced_search', Not Fair!!! Jun 5, 2020 at 13:13
2
$eavSetup->addAttribute(

        \Magento\Catalog\Model\Product::ENTITY,
        'lenscolor',/* Custom Attribute Code */
        [
            'group' => 'Color Details',
            'type' => 'text',
            'attribute_set' =>  'mycolor',
            'backend' => '',
            'frontend' => '',
            'label' => 'Lens Color', /* lablel of your attribute*/
            'input' => 'textarea',
            'class' => '',
            'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
            'visible' => true,
            'required' => false,
            'user_defined' => true,
            'default' => '',
            'searchable' => true,
            'filterable' => true,
            'comparable' => false,
            'visible_on_front' => true,
            'used_in_product_listing' => true,
            'unique' => false,
            'visible_in_advanced_search' => true  /* set true for enable advanced search while creating custom attribute */

        ]
    );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.