-
-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GUI to Edit EAV Attributes & Sets - Customer #2352
Draft
justinbeaty
wants to merge
18
commits into
OpenMage:main
Choose a base branch
from
justinbeaty:topic-eav-grid-customer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
330fca3
Mage_Eav: Add generic grid code
justinbeaty c6b6a1e
Mage_Eav: Add generic form element renderers
justinbeaty 7910592
Mage_Customer: Add EAV grids
justinbeaty 4d460bb
Mage_Customer: Add use_in_forms support
justinbeaty c8b8dea
WIP: GUI to set attribute sets for customer groups
justinbeaty 3d3ea2c
WIP: Change form based on customer group
justinbeaty e83aaaa
Merge branch '20.0' into topic-eav-grid-customer
sreichel c6bfdb6
Merge branch main
fballiano 4f55858
phpcs
fballiano 09df087
Merge branch 'main' into topic-eav-grid-customer
sreichel 1629a2b
phpcs
sreichel d8daadd
Merge branch 'main' into topic-eav-grid-customer
sreichel 41d4ae1
phpstan fix
sreichel 74c183b
Merge branch 'main' into topic-eav-grid-customer
sreichel 6a6cc3b
phpcbf
sreichel ccffb9d
Merge branch 'main' into topic-eav-grid-customer
sreichel 680b8c2
Merge branch 'main' into topic-eav-grid-customer
sreichel 93fc67c
phpcs and phpstan fixes
sreichel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
app/code/core/Mage/Adminhtml/Model/Customer/Observer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magento.com so we can send you a copy immediately. | ||
* | ||
* @category Mage | ||
* @package Mage_Adminhtml | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
|
||
/** | ||
* Customer EAV Observer | ||
* | ||
* @category Mage | ||
* @package Mage_Adminhtml | ||
* @author Magento Core Team <core@magentocommerce.com> | ||
*/ | ||
class Mage_Adminhtml_Model_Customer_Observer | ||
{ | ||
|
||
/** | ||
* Add frontend properties to customer attribute edit form | ||
* | ||
* @param Varien_Event_Observer $observer | ||
* @return $this | ||
*/ | ||
public function customerAttributeEditPrepareForm($observer) | ||
{ | ||
/** @var Mage_Customer_Model_Attribute $attribute */ | ||
$attribute = $observer->getAttribute(); | ||
|
||
/** @var Varien_Data_Form $form */ | ||
$form = $observer->getForm(); | ||
|
||
/** @var Varien_Data_Form_Element_Fieldset $fieldset */ | ||
$fieldset = $form->getElement('base_fieldset'); | ||
|
||
// frontend properties fieldset | ||
$fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Extra Properties'))); | ||
|
||
$fieldset->addField('use_in_forms', 'multiselect', array( | ||
'name' => 'use_in_forms', | ||
'label' => Mage::helper('adminhtml')->__('Use in Forms'), | ||
'title' => Mage::helper('adminhtml')->__('Use in Forms'), | ||
'values' => Mage::getModel('customer/config_forms')->toOptionArray(), | ||
'value' => Mage::getResourceModel('customer/form_attribute')->getFormTypesByAttribute($attribute) | ||
)); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Save frontend properties from customer attribute edit form | ||
* | ||
* @param Varien_Event_Observer $observer | ||
* @return $this | ||
*/ | ||
public function customerAttributeEditPrepareSave($observer) | ||
{ | ||
/** @var Mage_Core_Controller_Request_Http $request */ | ||
$request = $observer->getRequest(); | ||
|
||
$data = $request->getPost(); | ||
if ($data) { | ||
|
||
/** @var Mage_Eav_Model_Entity_Attribute $model */ | ||
$model = $observer->getObject(); | ||
|
||
if (!isset($data['use_in_forms'])) { | ||
$data['use_in_forms'] = array(); | ||
} | ||
|
||
$model->setData('used_in_forms', $data['use_in_forms']); | ||
|
||
} | ||
return $this; | ||
} | ||
|
||
/** | ||
* Add frontend properties to customer address attribute edit form | ||
* | ||
* @param Varien_Event_Observer $observer | ||
* @return $this | ||
*/ | ||
public function customerAddressAttributeEditPrepareForm($observer) | ||
{ | ||
/** @var Mage_Customer_Model_Attribute $attribute */ | ||
$attribute = $observer->getAttribute(); | ||
|
||
/** @var Varien_Data_Form $form */ | ||
$form = $observer->getForm(); | ||
|
||
/** @var Varien_Data_Form_Element_Fieldset $fieldset */ | ||
$fieldset = $form->getElement('base_fieldset'); | ||
|
||
// frontend properties fieldset | ||
$fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Extra Properties'))); | ||
|
||
$fieldset->addField('use_in_forms', 'multiselect', array( | ||
'name' => 'use_in_forms', | ||
'label' => Mage::helper('adminhtml')->__('Use in Forms'), | ||
'title' => Mage::helper('adminhtml')->__('Use in Forms'), | ||
'values' => Mage::getModel('customer/config_address_forms')->toOptionArray(), | ||
'value' => Mage::getResourceModel('customer/form_attribute')->getFormTypesByAttribute($attribute) | ||
)); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Save frontend properties from customer address attribute edit form | ||
* | ||
* @param Varien_Event_Observer $observer | ||
* @return $this | ||
*/ | ||
public function customerAddressAttributeEditPrepareSave($observer) | ||
{ | ||
/** @var Mage_Core_Controller_Request_Http $request */ | ||
$request = $observer->getRequest(); | ||
|
||
$data = $request->getPost(); | ||
if ($data) { | ||
|
||
/** @var Mage_Eav_Model_Entity_Attribute $model */ | ||
$model = $observer->getObject(); | ||
|
||
if (!isset($data['use_in_forms'])) { | ||
$data['use_in_forms'] = array(); | ||
} | ||
|
||
$model->setData('used_in_forms', $data['use_in_forms']); | ||
|
||
} | ||
return $this; | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
app/code/core/Mage/Adminhtml/controllers/Customer/Address/AttributeController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magento.com so we can send you a copy immediately. | ||
* | ||
* @category Mage | ||
* @package Mage_Adminhtml | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
require_once 'Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php'; | ||
|
||
/** | ||
* Customer address attribute controller | ||
* | ||
* @category Mage | ||
* @package Mage_Adminhtml | ||
* @author Magento Core Team <core@magentocommerce.com> | ||
*/ | ||
|
||
class Mage_Adminhtml_Customer_Address_AttributeController extends Mage_Eav_Controller_Adminhtml_Attribute_Abstract | ||
{ | ||
/** | ||
* Additional initialization | ||
* | ||
*/ | ||
protected function _construct() | ||
{ | ||
$this->_entityCode = Mage_Customer_Model_Address::ENTITY; | ||
} | ||
|
||
protected function _initAction() | ||
{ | ||
parent::_initAction(); | ||
|
||
$this->_title($this->__('Customers')) | ||
->_title($this->__('Attributes')) | ||
->_title($this->__('Manage Customer Address Attributes')); | ||
|
||
$this->_setActiveMenu('customer/attributes') | ||
->_addBreadcrumb( | ||
$this->__('Customers'), | ||
$this->__('Customers') | ||
) | ||
->_addBreadcrumb( | ||
$this->__('Manage Customer Address Attributes'), | ||
$this->__('Manage Customer Address Attributes') | ||
); | ||
|
||
return $this; | ||
} | ||
|
||
protected function _isAllowed() | ||
{ | ||
return Mage::getSingleton('admin/session')->isAllowed('customer/attributes/customer_address_attributes'); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
app/code/core/Mage/Adminhtml/controllers/Customer/Address/SetController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magento.com so we can send you a copy immediately. | ||
* | ||
* @category Mage | ||
* @package Mage_Adminhtml | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
require_once 'Mage/Eav/Controller/Adminhtml/Set/Abstract.php'; | ||
|
||
/** | ||
* Customer address attribute sets controller | ||
* | ||
* @category Mage | ||
* @package Mage_Adminhtml | ||
* @author Magento Core Team <core@magentocommerce.com> | ||
*/ | ||
|
||
class Mage_Adminhtml_Customer_Address_SetController extends Mage_Eav_Controller_Adminhtml_Set_Abstract | ||
{ | ||
/** | ||
* Additional initialization | ||
* | ||
*/ | ||
protected function _construct() | ||
{ | ||
$this->_entityCode = Mage_Customer_Model_Address::ENTITY; | ||
} | ||
|
||
protected function _initAction() | ||
{ | ||
parent::_initAction(); | ||
|
||
$this->_title($this->__('Customers')) | ||
->_title($this->__('Attributes')) | ||
->_title($this->__('Manage Customer Address Attribute Sets')); | ||
|
||
$this->_setActiveMenu('customer/attributes') | ||
->_addBreadcrumb( | ||
$this->__('Customers'), | ||
$this->__('Customers') | ||
) | ||
->_addBreadcrumb( | ||
$this->__('Manage Customer Address Attribute Sets'), | ||
$this->__('Manage Customer Address Attribute Sets') | ||
); | ||
|
||
return $this; | ||
} | ||
|
||
protected function _isAllowed() | ||
{ | ||
return Mage::getSingleton('admin/session')->isAllowed('customer/attributes/customer_address_sets'); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looking at #2260 again, not sure why I implemented a new method instead of using
$attribute->getUsedInForms()