Skip to content
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 #25

Open
wants to merge 137 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
1ff7e68
Mage_Eav: Add generic grid code
justinbeaty Aug 3, 2022
851e567
Mage_Eav: Add generic form element renderers
justinbeaty Aug 3, 2022
e86bf29
Mage_Catalog: add EAV grids
justinbeaty Jul 13, 2022
42524db
Mage_Customer: Add EAV grids
justinbeaty Jul 13, 2022
c3fff1f
Mage_Customer: Add use_in_forms support
justinbeaty Aug 1, 2022
ab6a3fa
WIP: GUI to set attribute sets for customer groups
justinbeaty Aug 3, 2022
0e0c4dd
WIP: Change form based on customer group
justinbeaty Aug 3, 2022
a88557b
phpcs
fballiano Sep 19, 2024
69ffce0
Fix category controllers to extend correct class.
justinbeaty Sep 19, 2024
0383ab5
File headers + merge
fballiano Sep 19, 2024
12439ab
File headers
fballiano Sep 19, 2024
8e085f9
PHPStan
fballiano Sep 19, 2024
01a5dbb
PHPCS
fballiano Sep 19, 2024
346324c
Fixed bug with filtering grid across different entity types
fballiano Sep 19, 2024
dbf0e1a
Fixed bug with filtering grid across different entity types
fballiano Sep 19, 2024
d28843e
require_once not needed
fballiano Sep 19, 2024
99ac573
PHPStan
fballiano Sep 19, 2024
ee1dc95
Merge branch 'main' into topic-eav-grid-maho
fballiano Sep 19, 2024
cee3d2c
Added Override notation
fballiano Sep 19, 2024
ac372b3
PHPStan and reformat
fballiano Sep 19, 2024
9145677
Fixed active menu (sreichel)
justinbeaty Sep 24, 2024
632c998
Remove scope option from base EAV code
justinbeaty Sep 24, 2024
6a2ba6c
WIP: Add website switcher to customer attribute edit form
justinbeaty Sep 25, 2024
817c3e9
Support attributes with website tables
justinbeaty Sep 27, 2024
aea7bde
phpstan
justinbeaty Sep 27, 2024
938bf2f
Merge branch 'main' into topic-eav-grid-maho
fballiano Sep 28, 2024
45572a0
Rector
fballiano Sep 28, 2024
5c63c64
Fix use_in_forms
justinbeaty Sep 28, 2024
2faf08e
fixes
justinbeaty Sep 28, 2024
46cb59b
hide some attributes from grid
justinbeaty Sep 28, 2024
ba0b154
phpstan
justinbeaty Sep 28, 2024
7ee6573
add extra fields to another phtml file, may still be missing some...
justinbeaty Sep 28, 2024
86cf0c5
add install script
justinbeaty Sep 28, 2024
b6e792b
Support custom form types via config.xml
justinbeaty Sep 28, 2024
857709e
PHPStan
fballiano Sep 28, 2024
e1cada7
Merge branch 'main' into topic-eav-grid-maho
fballiano Sep 28, 2024
e4f3862
Fixed docblock
fballiano Sep 28, 2024
8d94b5d
Generic EAV used_in_forms code
justinbeaty Sep 28, 2024
81a2faf
Remove new function getFormTypesByAttribute
justinbeaty Sep 29, 2024
93fb420
Merge branch main
fballiano Oct 1, 2024
99cd461
Merge branch 'main' into topic-eav-grid-maho
fballiano Oct 1, 2024
2ea282a
Fixes, possibly broke something else, WIP
justinbeaty Oct 2, 2024
d2b6331
phpcs
justinbeaty Oct 14, 2024
53c61db
revert .phpstan.baseline.neon
justinbeaty Oct 14, 2024
736bf19
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Oct 14, 2024
90d9752
phpstan
justinbeaty Oct 14, 2024
2400274
Reorder some fields, add field dependence, move blocks to lib/Varien,…
justinbeaty Oct 14, 2024
3b14a35
phpstan
justinbeaty Oct 15, 2024
29c94e7
phpcs
justinbeaty Oct 15, 2024
628a7de
Multiline max, and allow for customer type
justinbeaty Oct 15, 2024
12aced3
fix
justinbeaty Oct 15, 2024
f04a969
Use boolean type
justinbeaty Oct 15, 2024
967648d
Testing rendering all fields from group
justinbeaty Oct 15, 2024
b01f7c7
Merge branch 'main' into topic-eav-grid-maho
fballiano Oct 15, 2024
9e325ee
short echo syntax
justinbeaty Oct 15, 2024
487dd3a
add validation classes (thx empiricompany)
justinbeaty Oct 15, 2024
12680d0
phpcs
justinbeaty Oct 15, 2024
71aa642
validation class fix
justinbeaty Oct 15, 2024
ed1ebaa
Testing rendering all fields from group part 2
justinbeaty Oct 15, 2024
e055f5f
Merge branch 'main' into topic-eav-grid-maho
fballiano Oct 16, 2024
f084d1e
Hide attributes from group
justinbeaty Oct 16, 2024
22f68bd
move load out of loop
justinbeaty Oct 16, 2024
d66d790
Add Dropdown with Other Option input type
justinbeaty Oct 16, 2024
96bfc4c
Merge branch 'main' into topic-eav-grid-maho
fballiano Oct 18, 2024
e15c6e8
fix, don't store customselect with source_table
justinbeaty Oct 19, 2024
1222b6a
Fix customer validate
justinbeaty Oct 19, 2024
c6e6419
Customselect fixes
justinbeaty Oct 20, 2024
cfafda9
Remove Name and Address Options Config
justinbeaty Oct 20, 2024
aa2a75f
Customer helper prefix/suffix/street lines
justinbeaty Oct 20, 2024
487b10b
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Oct 20, 2024
1751a24
PHPStan baseline
justinbeaty Oct 20, 2024
b3f055d
working on forms
justinbeaty Oct 20, 2024
a418c09
fix
justinbeaty Oct 20, 2024
7bc270a
phpcs
justinbeaty Oct 20, 2024
76507dd
Move rwd templates to base
justinbeaty Oct 20, 2024
30c42a8
Pretty sure these are obsolete template files
justinbeaty Oct 20, 2024
d739384
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Oct 21, 2024
9c56a21
fix
justinbeaty Oct 21, 2024
6b2893f
working on templates with two forms, temp...
justinbeaty Oct 21, 2024
5ae2781
Merge branch 'main' into topic-eav-grid-maho
fballiano Oct 21, 2024
30b1310
Created new Mage_Eav_Block_Widget_Form in the spirit of Mage_Adminhtm…
justinbeaty Oct 22, 2024
ef361ed
phpstan
justinbeaty Oct 23, 2024
319eb68
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Oct 23, 2024
c94a432
Fix Varien.DateElement call, however value isn't saving, will investi…
justinbeaty Oct 23, 2024
c2db77b
phpcs
justinbeaty Oct 23, 2024
8663a04
Fieldset CSS spacing
justinbeaty Oct 23, 2024
fe3da46
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Oct 23, 2024
6b99b5b
Merge branch 'main' into topic-eav-grid-maho
fballiano Oct 29, 2024
cd09a2d
Fix region select, support use of data attribute
justinbeaty Oct 29, 2024
f6bf992
Fix date input
justinbeaty Oct 29, 2024
0f587b6
Allow set attribute set for not logged in customer
justinbeaty Oct 29, 2024
be74bff
Move install script to maho_setup
justinbeaty Oct 29, 2024
23d6ab2
Misc customer group edit changes
justinbeaty Oct 29, 2024
3ef4244
Fix for using the correct object in merged forms
justinbeaty Oct 29, 2024
63e5034
safer attribute set id getter
justinbeaty Oct 29, 2024
d052306
move some logic around
justinbeaty Oct 29, 2024
9379a0c
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Oct 29, 2024
58d73ff
phpstan baseline
justinbeaty Oct 29, 2024
691d23a
Merge branch 'main' into topic-eav-grid-maho
fballiano Oct 31, 2024
2618a34
updated baseline
fballiano Oct 31, 2024
c6d3c76
remove hardcoded attribute set ids
justinbeaty Oct 31, 2024
57a7b0d
Merge branch 'topic-eav-grid-maho' of github.com:justinbeaty/maho int…
justinbeaty Oct 31, 2024
aff0235
Merge branch 'main' into topic-eav-grid-maho
fballiano Oct 31, 2024
b450e39
PHPCS
fballiano Oct 31, 2024
b2668f1
Install script
justinbeaty Nov 1, 2024
3c5130f
Integrating changes since PR was originally created in OM
justinbeaty Nov 2, 2024
cee5600
Integrating changes since PR was originally created in OM
justinbeaty Nov 2, 2024
e798580
Make Mage_Adminhtml_Catalog_Product_SetController more like generic one
justinbeaty Nov 2, 2024
f4bc67f
use consistent registry key
justinbeaty Nov 2, 2024
a9f7ae7
PHPStan
justinbeaty Nov 2, 2024
8f20977
camelCase
justinbeaty Nov 2, 2024
ece8279
Use ADMIN_RESOURCE const
justinbeaty Nov 2, 2024
ed37d4c
misc
justinbeaty Nov 2, 2024
7326dc1
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Nov 2, 2024
56a1437
ref OM 1544
justinbeaty Nov 2, 2024
303c2e6
Make Mage_Adminhtml_Catalog_Product_AttributeController more like gen…
justinbeaty Nov 2, 2024
011261f
Ref OM 2875 + simplify logic
justinbeaty Nov 3, 2024
4a9c44f
Consolidate logic in eav helper, deprecate methods
justinbeaty Nov 3, 2024
ed8e6df
Big refactor
justinbeaty Nov 5, 2024
ac849aa
add setTemplateIfExists method
justinbeaty Nov 23, 2024
be4ed29
Big refactor part 2
justinbeaty Nov 23, 2024
e8fa727
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Nov 23, 2024
9044528
templates
justinbeaty Nov 23, 2024
84f37de
Use match expression
justinbeaty Nov 23, 2024
4cad548
Some fixes
justinbeaty Nov 23, 2024
a69ba7b
avoid loading collection in loop
justinbeaty Nov 23, 2024
c2f2f84
Fixes
justinbeaty Nov 24, 2024
2b5c4d0
PHPStan
justinbeaty Nov 24, 2024
fae23a8
phpcs, rector
justinbeaty Nov 24, 2024
5d3fcf2
copyright
justinbeaty Nov 24, 2024
6c0b4d5
phpcs
justinbeaty Nov 24, 2024
72c2ac3
Merge branch 'main' into topic-eav-grid-maho
fballiano Nov 24, 2024
690824d
Merge branch 'main' into topic-eav-grid-maho
fballiano Nov 24, 2024
74ab193
Merge branch 'main' into topic-eav-grid-maho
justinbeaty Dec 9, 2024
7b1dfea
update baseline
justinbeaty Dec 9, 2024
6f929f7
Fix later conflict
justinbeaty Dec 9, 2024
6c095c6
Fix later conflict
justinbeaty Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ protected function _getAdditionalElementTypes()
{
return [
'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_category_helper_image'),
'textarea' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_helper_form_wysiwyg')
'textarea' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_helper_form_wysiwyg'),
'boolean' => Mage::getConfig()->getBlockClassName('eav/adminhtml_helper_form_boolean'),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function initForm()

$addressModel = Mage::getModel('customer/address');
$addressModel->setCountryId(Mage::helper('core')->getDefaultCountry($customer->getStore()));
$addressModel->setCustomer($customer);
/** @var Mage_Customer_Model_Form $addressForm */
$addressForm = Mage::getModel('customer/form');
$addressForm->setFormCode('adminhtml_customer_address')
Expand Down
33 changes: 33 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,39 @@ protected function _prepareLayout()
]
);

// show attribute set fields for all groups except not logged in
if (is_null($customerGroup->getId()) || (int)$customerGroup->getId() !== Mage_Customer_Model_Group::NOT_LOGGED_IN_ID) {
$setsCustomer = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter(Mage::getResourceModel('customer/customer')->getEntityType()->getId())
->setOrder('attribute_set_name', 'asc')
->load()
->toOptionArray();

$fieldset->addField('customer_attribute_set_id', 'select', [
'name' => 'customer_attribute_set',
'label' => Mage::helper('customer')->__('Customer Attribute Set'),
'title' => Mage::helper('customer')->__('Customer Attribute Set'),
'class' => 'required-entry',
'required' => true,
'values' => $setsCustomer
]);

$setsAddress = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter(Mage::getResourceModel('customer/address')->getEntityType()->getId())
->setOrder('attribute_set_name', 'asc')
->load()
->toOptionArray();

$fieldset->addField('customer_address_attribute_set_id', 'select', [
'name' => 'customer_address_attribute_set',
'label' => Mage::helper('customer')->__('Customer Address Attribute Set'),
'title' => Mage::helper('customer')->__('Customer Address Attribute Set'),
'class' => 'required-entry',
'required' => true,
'values' => $setsAddress
]);
}

if (!is_null($customerGroup->getId())) {
// If edit add id
$form->addField(
Expand Down
129 changes: 129 additions & 0 deletions app/code/core/Mage/Adminhtml/Model/Customer/Observer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
/**
* Maho
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
* @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Customer EAV Observer
*
* @category Mage
* @package Mage_Adminhtml
*/
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', ['legend' => Mage::helper('adminhtml')->__('Extra Properties')]);

$fieldset->addField('use_in_forms', 'multiselect', [
'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'] = [];
}

$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();

// frontend properties fieldset
$fieldset = $form->addFieldset('front_fieldset', ['legend' => Mage::helper('adminhtml')->__('Extra Properties')]);

$fieldset->addField('use_in_forms', 'multiselect', [
'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'] = [];
}

$model->setData('used_in_forms', $data['use_in_forms']);
}
return $this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Maho
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
* @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

require_once 'Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php';

/**
* Catalog category attribute controller
*
* @category Mage
* @package Mage_Adminhtml
*/
class Mage_Adminhtml_Catalog_Category_AttributeController extends Mage_Eav_Controller_Adminhtml_Attribute_Abstract
{
protected function _construct()
{
$this->_entityCode = Mage_Catalog_Model_Category::ENTITY;
}

protected function _initAction()
{
parent::_initAction();

$this->_title($this->__('Catalog'))
->_title($this->__('Attributes'))
->_title($this->__('Manage Category Attributes'));

$this->_setActiveMenu('catalog/attributes')
->_addBreadcrumb(
$this->__('Catalog'),
$this->__('Catalog')
)
->_addBreadcrumb(
$this->__('Manage Category Attributes'),
$this->__('Manage Category Attributes')
);

return $this;
}

protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/category_attributes');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Maho
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

require_once 'Mage/Eav/Controller/Adminhtml/Set/Abstract.php';

/**
* Catalog category attribute sets controller
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Adminhtml_Catalog_Category_SetController extends Mage_Eav_Controller_Adminhtml_Set_Abstract
{
protected function _construct()
{
$this->_entityCode = Mage_Catalog_Model_Category::ENTITY;
}

protected function _initAction()
{
parent::_initAction();

$this->_title($this->__('Catalog'))
->_title($this->__('Attributes'))
->_title($this->__('Manage Category Attribute Sets'));

$this->_setActiveMenu('catalog/attributes')
->_addBreadcrumb(
$this->__('Catalog'),
$this->__('Catalog')
)
->_addBreadcrumb(
$this->__('Manage Category Attribute Sets'),
$this->__('Manage Category Attribute Sets')
);

return $this;
}

protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/category_sets');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Maho
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
* @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
* @license https://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
*/
class Mage_Adminhtml_Customer_Address_AttributeController extends Mage_Eav_Controller_Adminhtml_Attribute_Abstract
{
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');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Maho
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
* @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
* @license https://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
*/
class Mage_Adminhtml_Customer_Address_SetController extends Mage_Eav_Controller_Adminhtml_Set_Abstract
{
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');
}
}
Loading
Loading