3

I would like to have my customers upload an image on their account page. I can add an image attribute to my customer model by using the following code. Any idea on how to put this on the frontend and make it work?

$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'logo', array(
            'type'     => 'varchar',
            'backend' => '',
            'label'    => 'Logo',
            'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image',
            'input'    => 'image',
            'visible'  => true,
            'required' => false,
            'default' => '0',
            'frontend' => '',
            'unique'     => false,
            'note'       => '',
            'system'    => false,
            'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE
        ));

$logo = $customerSetup->getAttribute(\Magento\Customer\Model\Customer::ENTITY, "logo");

    $logo = $customerSetup->getEavConfig()->getAttribute('customer', 'logo');
    $used_in_forms2[]="adminhtml_customer";
    $used_in_forms2[]="customer_account_edit";
    $logo->setData("used_in_forms", $used_in_forms2)
        ->setData("is_used_for_customer_segment", true)
        ->setData("is_system", 0)
        ->setData("is_user_defined", 1)
        ->setData("is_visible", 1)
        ->setData("sort_order", 101);

    $logo->save();
1
  • Did you get the solution ?
    – Jsparo30
    Jul 23, 2017 at 22:16

1 Answer 1

0

You can you use my extension - "Profile Avatar", look up on marketplace.

Extension provide:

  • Customer dashboard section with upload tools
  • Show profile images in user list on product page

and you will can use my block views for your projects

marketplace direct link on these extension: http://marketplace.magento.com/sy-avatar.html

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.