Skip to content

Commit bd57adf

Browse files
authored
Merge pull request #1 from landofcoder/develop
update module customer information
2 parents 3d85480 + 986f39b commit bd57adf

File tree

7 files changed

+158
-15
lines changed

7 files changed

+158
-15
lines changed

Setup/UpgradeData.php

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,64 @@
2222
*/
2323

2424
namespace Lof\CustomCustomerInfo\Setup;
25-
2625
use Magento\Framework\Setup\UpgradeDataInterface;
27-
use Magento\Framework\Setup\ModuleContextInterface;
2826
use Magento\Framework\Setup\ModuleDataSetupInterface;
27+
use Magento\Framework\Setup\ModuleContextInterface;
28+
use Magento\Customer\Setup\CustomerSetupFactory;
29+
use Magento\Customer\Model\Customer;
30+
use Magento\Eav\Model\Entity\Attribute\Set as AttributeSet;
31+
use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory;
32+
2933

30-
class UpgradeData implements UpgradeDataInterface
31-
{
34+
class UpgradeData implements UpgradeDataInterface {
3235

33-
/**
34-
* {@inheritdoc}
35-
*/
36-
public function upgrade(
37-
ModuleDataSetupInterface $setup,
38-
ModuleContextInterface $context
36+
protected $customerSetupFactory;
37+
private $attributeSetFactory;
38+
39+
public function __construct(
40+
CustomerSetupFactory $customerSetupFactory, AttributeSetFactory $attributeSetFactory
3941
) {
40-
if (version_compare($context->getVersion(), "1.0.0", "<")) {
41-
//Your upgrade script
42+
$this->customerSetupFactory = $customerSetupFactory;
43+
$this->attributeSetFactory = $attributeSetFactory;
44+
}
45+
46+
47+
public function upgrade( ModuleDataSetupInterface $setup, ModuleContextInterface $context ) {
48+
49+
if (version_compare($context->getVersion(), '1.0.4') < 0) {
50+
51+
$setup->startSetup();
52+
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
53+
54+
$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
55+
$attributeSetId = $customerEntity->getDefaultAttributeSetId();
56+
57+
$attributeSet = $this->attributeSetFactory->create();
58+
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
59+
60+
$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'customer_avatar', [
61+
'type' => 'text',
62+
'label' => 'Image',
63+
'input' => 'file',
64+
"source" => '',
65+
'required' => false,
66+
'default' => '0',
67+
'visible' => true,
68+
'user_defined' => true,
69+
'sort_order' => 210,
70+
'position' => 210,
71+
'system' => false,
72+
]);
73+
74+
$image = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'customer_avatar')
75+
->addData([
76+
'attribute_set_id' => $attributeSetId,
77+
'attribute_group_id' => $attributeGroupId,
78+
'used_in_forms' => ['adminhtml_customer', 'customer_account_create', 'customer_account_edit'],
79+
]);
80+
81+
$image->save();
82+
$setup->endSetup();
4283
}
4384
}
44-
}
85+
}

etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" ?>
1+
<?xml version="1.1" ?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
33
<default>
44
<lofsubcustomeraccount>

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" ?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Lof_CustomCustomerInfo" setup_version="1.0.0">
3+
<module name="Lof_CustomCustomerInfo" setup_version="1.0.1">
44
<sequence>
55
<module name="Magento_Customer"/>
66
</sequence>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
3+
<body>
4+
<referenceContainer name="form.additional.info">
5+
<block class="Magento\Framework\View\Element\Template" name="additional_field_register" template="Lof_CustomCustomerInfo::additionalfieldregister.phtml"/>
6+
</referenceContainer>
7+
</body>
8+
</page>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
3+
<body>
4+
<referenceContainer name="form.additional.info">
5+
<block class="Magento\Framework\View\Element\Template" name="customerinfo_edit" template="Lof_CustomCustomerInfo::customeredit.phtml" cacheable="false">
6+
</block>
7+
</referenceContainer>
8+
</body>
9+
</page>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<fieldset class="fieldset create account" data-hasrequired="<?php /* @escapeNotVerified */
2+
?>">
3+
<legend class="legend"><span><?php /* @escapeNotVerified */
4+
echo __('Additional Information') ?></span></legend>
5+
6+
<p>
7+
<div class="field twilio_image required">
8+
<label for="twilio_image" class="label"><span><?php /* @escapeNotVerified */
9+
echo __('Avatar') ?></span></label>
10+
<div class="control">
11+
<input type="file" name="twilio_image" id="twilio_image" title="<?php /* @escapeNotVerified */
12+
echo __('Image') ?>">
13+
</div>
14+
</div>
15+
<div class="field twilio_image required">
16+
<label for="facebook" class="label"><span><?= $block->escapeHtml(__('Facebook')) ?></span></label>
17+
<div class="control">
18+
<input type="text" name="facebook" autocomplete="facebook" id="facebook" value="" class="input-text" data-validate="{required:true}">
19+
</div>
20+
</div>
21+
<div class="field twilio_image required">
22+
<label for="job" class="label"><span><?= $block->escapeHtml(__('Job')) ?></span></label>
23+
<div class="control">
24+
<input type="text" name="job" autocomplete="job" id="job" value="" class="input-text" data-validate="{required:true}">
25+
</div>
26+
</div>
27+
<div class="field twilio_image required">
28+
<label for="twitter" class="label"><span><?= $block->escapeHtml(__('Twitter')) ?></span></label>
29+
<div class="control">
30+
<input type="text" name="twitter" autocomplete="twitter" id="twitter" value="" class="input-text" data-validate="{required:true}">
31+
</div>
32+
</div>
33+
<div class="field twilio_image required">
34+
<label for="customer_id" class="label"><span><?= $block->escapeHtml(__('Customer_id')) ?></span></label>
35+
<div class="control">
36+
<input type="text" name="customer_id" autocomplete="customer_id" id="customer_id" value="" class="input-text" data-validate="{required:true}">
37+
</div>
38+
</div>
39+
<div class="field twilio_image required">
40+
<label for="avatar" class="label"><span><?= $block->escapeHtml(__('avatar')) ?></span></label>
41+
<div class="control">
42+
<input type="text" name="avatar" autocomplete="avatar" id="avatar" value="" class="input-text" data-validate="{required:true}">
43+
</div>
44+
</div>
45+
<div class="field twilio_image required">
46+
<label for="bio" class="label"><span><?= $block->escapeHtml(__('Bio')) ?></span></label>
47+
<div class="control">
48+
<input type="text" name="bio" autocomplete="bio" id="bio" value="" class="input-text" data-validate="{required:true}">
49+
</div>
50+
</div>
51+
</p></fieldset>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php $objm = \Magento\Framework\App\ObjectManager::getInstance(); ?>
2+
<?php $customerSession = $objm->get('Magento\Customer\Model\Session'); ?>
3+
<fieldset class="fieldset info">
4+
?>">
5+
<div class="field required">
6+
<label class="label" for="facebook"><span><?= $block->escapeHtml(__('Facebook')) ?></span></label>
7+
<div class="control">
8+
<input type="text" value="<?php echo $customerSession->getCustomer()->getFacebook();?>" name="facebook" id="facebook" data-input="facebook" class="input-text" data-validate="{required:true}" /><br>
9+
</div>
10+
<br>
11+
<label class="label" for="job"><span><?= $block->escapeHtml(__('Job')) ?></span></label>
12+
<div class="control">
13+
<input type="text" value="<?php echo $customerSession->getCustomer()->getJob();?>" name="job" id="job" data-input="job" class="input-text" data-validate="{required:true}" /><br>
14+
</div><br>
15+
<label class="label" for="bio"><span><?= $block->escapeHtml(__('Bio')) ?></span></label>
16+
<div class="control">
17+
<input type="text" value="<?php echo $customerSession->getCustomer()->getBio();?>" name="bio" id="bio" data-input="bio" class="input-text"
18+
data-validate="{required:true}" />
19+
</div><br>
20+
<label class="label" for="twitter"><span><?= $block->escapeHtml(__('Twitter')) ?></span></label>
21+
<div class ="control">
22+
<input type="text" value="<?php echo $customerSession->getCustomer()->getTwitter();?>" name="twitter" id="twitter" data-input="twitter" class="input-text"
23+
data-validate="{required:true}" />
24+
</div><br>
25+
<label class="label" for="avatar"><span><?= $block->escapeHtml(__('avatar')) ?></span></label>
26+
<div class="control">
27+
<input type="text" value="<?php echo $customerSession->getCustomer()->getavatar();?>" name="avatar" id="avatar" data-input="avatar" class="input-text"
28+
data-validate="{required:true}" />
29+
</div><br>
30+
<label class="label" for="avatar"><span><?= $block->escapeHtml(__('Customer_Id')) ?></span></label>
31+
<input type="text" value="<?php echo $customerSession->getCustomer()->getavatar();?>" name="customer_id" id="customer_id" data-input="customer_id" class="input-text"
32+
data-validate="{required:true}" />
33+
</div>
34+
</fieldset>

0 commit comments

Comments
 (0)