Ich möchte ein Kunden-Bild-Attribut erstellen, so können Kunden und Admin Profilbild wie Avatar hochladen, aktualisieren und löschen. Ich weiß, wie ist das möglich in Magento 1, aber nicht in Magento 2 . Wenn jemand eine Idee haben, bitte teilen. Danke im Voraus.So laden Sie Kundenprofil Bild in Magento 2
0
A
Antwort
0
erstellen Sie unter Moduldateien. Es funktionierte auf magento 2.1.4
erstellen: app \ code \ Sashas \ CustomerAttribute \ etc \ module.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Sashas_CustomerAttribute" setup_version="1.0.0">
<sequence>
<module name="Magento_Customer"/>
</sequence>
</module>
</config>
erstellen: app \ code \ Sashas \ CustomerAttribute \ Setup \ InstallData.php
<?php
/**
* @author Sashas
* @category Sashas
* @package Sashas_CustomerAttribute
* @copyright Copyright (c) 2015 Sashas IT Support Inc. (http://www.extensions.sashas.org)
*/
namespace Sashas\CustomerAttribute\Setup;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Customer\Model\Customer;
use Magento\Eav\Model\Entity\Attribute\Set as AttributeSet;
use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
/**
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface
{
/**
* @var CustomerSetupFactory
*/
protected $customerSetupFactory;
/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;
/**
* @param CustomerSetupFactory $customerSetupFactory
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
AttributeSetFactory $attributeSetFactory
) {
$this->customerSetupFactory = $customerSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;
}
/**
* {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();
/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
$customerSetup->addAttribute(Customer::ENTITY, 'magento_username', [
'type' => 'varchar',
'label' => 'Magento Username',
'input' => 'image',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);
$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'magento_username')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer'],
]);
$attribute->save();
}
}
erstellen: app \ code \ Sashas \ CustomerAttribute \ registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Sashas_customerAttribute',
__DIR__
);
?>
+0
Könnten Sie bitte vollständige Antwort geben? – Jsparo30
Verwandte Themen
- 1. So laden Sie die Erweiterung in Magento 2
- 2. Magento 2 Laden spezifisches Attribut am Frontend
- 3. So überschreiben Sie die JS-Ressource in Magento 2 Checkout
- 4. So finden Sie in Verkauf/Bestellung/Drucken/Seite Magento 2?
- 5. Magento 2: So rufen Sie Logo in PHP-Datei
- 6. So entfernen Sie das Mengenfeld in der Magento 2 Produktseite
- 7. So laden Sie ein Bild von Django
- 8. So laden Sie ein Bild mit jQuery
- 9. So laden Sie Bild von URL
- 10. So laden Sie eine JS-Datei auf Magento Admin-Dashboard
- 11. Erhalte Bilddaten in Magento 2
- 12. Magento 2: So erhalten Sie benutzerdefinierte Produktattribute im benutzerdefinierten Versandmodul
- 13. So laden Sie das umbenannte Bild in Code-Signierer
- 14. So laden Sie das Bild in die Mitte des Dokuments
- 15. So laden Sie ein Bild in iPhone-Anwendung
- 16. So laden Sie ein Bild in ein Objekt
- 17. So laden Sie ein PNG-Bild in ein TImage
- 18. So laden Sie ein Bild in HTML5-Canvas hoch
- 19. So laden Sie ein Bild in den Mailer
- 20. So laden Sie ein URL-Bild in eine vorhandene Listenansicht
- 21. So ändern Sie Magento-Front-End-Seiten
- 22. So laden Sie große Dateien in Python 2
- 23. So laden Sie 2 Datenbanktabellen in den gleichen Gridgain-Cache
- 24. So laden Sie 2 Dateien in Xamarin Android
- 25. So laden Sie untergeordnete Route standardmäßig in Winkel 2
- 26. wie base64 code zu bild in magento 2 konvertieren
- 27. So laden Sie ein bestimmtes Bild aus Assets mit Swift
- 28. So erhalten Sie doppelte Artikel in Magento
- 29. So zeigen Sie Themen in Magento
- 30. So entfernen Sie alle Katalogprodukte in Magento
i, Hdid Sie erhalten eine Lösung? – Jsparo30