0

I have added an attribute to my category. The attribute is working well on backend (it's showing and saving correctly), but I can't get it on the front.

Here's how i've added this (install):

        $eavSetup->addAttribute(
        \Magento\Catalog\Model\Category::ENTITY,
        'add_to_franco',
        [
            'type' => 'int',
            'label' => 'franco',
            'input' => 'boolean',
            'sort_order' => 333,
            'source' => '',
            'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
            'global' => 1,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'default' => null,
            'group' => 'General Information',
            'system' => false,
            'searchable' => true,
            'filterable' => true,
            'comparable' => true,
            'visible_on_front' => true,
            'used_in_product_listing' => true,
            'unique' => false,
            'apply_to' => ''

        ]
    );

This is the data i'm getting :

Array
(
    [entity_id] => 16
    [attribute_set_id] => 3
    [parent_id] => 2
    [created_at] => 2018-06-21 11:00:46
    [updated_at] => 2020-05-11 12:18:35
    [path] => 1/2/16
    [position] => 2
    [level] => 2
    [children_count] => 16
    [store_id] => 1
    [adresse_fournisseur] => 
    [all_children] => 
    [available_sort_by] => 
    [children] => 
    [custom_apply_to_products] => 0
    [custom_design] => 
    [custom_design_from] => 
    [custom_design_to] => 
    [custom_layout_update] => 
    [custom_use_parent_settings] => 0
    [default_sort_by] => 
    [description] => 
    [display_mode] => PRODUCTS
    [filter_price_range] => 
    [image] => 
    [include_in_menu] => 1
    [is_active] => 1
    [is_anchor] => 1
    [landing_page] => 
    [meta_description] => 
    [meta_keywords] => 
    [meta_title] => 
    [name] => Mes outils de communication
    [page_layout] => 
    [path_in_store] => 
    [poids_recherche] => 
    [url_key] => mes-outils-de-communication
    [url_path] => mes-outils-de-communication
)

And this is how i get the data :

 $cat = $objectManager->create('Magento\Catalog\Model\Category')->load($category);
 $data = $cat->toArray();

1 Answer 1

1

In your db eav_attribute table search your attrtibute and set user_defined = true

and than run following command

php bin/magento indexer:reindex
1

Your Answer

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

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