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 "Customer Attributes" and "Customer Address Attributes" #2260

Closed
wants to merge 17 commits into from
36 changes: 36 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Customer/Address/Attribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Magento
*
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @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)
*/

class Mage_Adminhtml_Block_Customer_Address_Attribute extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_controller = 'customer_address_attribute';
$this->_headerText = Mage::helper('customer')->__('Manage Customer Address Attributes');
$this->_addButtonLabel = Mage::helper('customer')->__('Add New Attribute');
parent::__construct();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
* Magento
*
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @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)
*/

class Mage_Adminhtml_Block_Customer_Address_Attribute_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
$this->_objectId = 'attribute_id';
$this->_controller = 'customer_address_attribute';

parent::__construct();

if($this->getRequest()->getParam('popup')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have forgotten a space.

$this->_removeButton('back');
$this->_addButton(
'close',
array(
'label' => Mage::helper('catalog')->__('Close Window'),
'class' => 'cancel',
'onclick' => 'window.close()',
'level' => -1
)
);
} else {
$this->_addButton(
'save_and_edit_button',
array(
'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
'onclick' => 'saveAndContinueEdit()',
'class' => 'save'
),
100
);
}

$this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Attribute'));
$this->_updateButton('save', 'onclick', 'saveAttribute()');

if (! Mage::registry('entity_attribute')->getIsUserDefined()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have added a extra space.

$this->_removeButton('delete');
} else {
$this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Attribute'));
}
}

public function getHeaderText()
{
if (Mage::registry('entity_attribute')->getId()) {
$frontendLabel = Mage::registry('entity_attribute')->getFrontendLabel();
if (is_array($frontendLabel)) {
$frontendLabel = $frontendLabel[0];
}
return Mage::helper('catalog')->__('Edit Customer Attribute "%s"', $this->escapeHtml($frontendLabel));
}
else {
return Mage::helper('catalog')->__('New Customer Attribute');
}
}

public function getValidationUrl()
{
return $this->getUrl('*/*/validate', array('_current'=>true));
}

public function getSaveUrl()
{
return $this->getUrl('*/'.$this->_controller.'/save', array('_current'=>true, 'back'=>null));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have forgotten the copy comment (you have added it elsewhere).

class Mage_Adminhtml_Block_Customer_Address_Attribute_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$form = new Varien_Data_Form(['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have forgotten the copy comment (you have added it elsewhere).

class Mage_Adminhtml_Block_Customer_Address_Attribute_Edit_Tab_Main
extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
protected function _prepareForm()
{
parent::_prepareForm();

$helper = Mage::helper('customer');
$attribute = $this->getAttributeObject();
$form = $this->getForm();

// frontend properties fieldset
$fieldset = $form->addFieldset('front_fieldset', [
'legend' => $helper->__('Frontend Properties')
]);
Comment on lines +16 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also add is_visible field to be editable here

$fieldset->addField('sort_order', 'text', [
'name' => 'sort_order',
'label' => $helper->__('Sort Order'),
'title' => $helper->__('Sort Order'),
'class' => 'validate-digits'
]);

$fieldset->addField('used_in_forms', 'multiselect', array(
'name' => 'used_in_forms',
'label' => $helper->__('Forms to Use In'),
'title' => $helper->__('Forms to Use In'),
'value' => $attribute->getUsedInForms(),
'can_be_empty' => true,
'values' => [
[
'label' => Mage::helper('customer')->__('Customer Address Registration'),
'value' => 'customer_register_address'
],
[
'label' => Mage::helper('customer')->__('Customer Account Address'),
'value' => 'customer_address_edit'
]
]
))->setSize(4);

Mage::dispatchEvent('adminhtml_customer_address_attribute_edit_prepare_form', array(
'form' => $form,
'attribute' => $attribute
));

return $this;
}

public function getTabLabel()
{
return Mage::helper('customer')->__('Properties');
}

public function getTabTitle()
{
return Mage::helper('customer')->__('Properties');
}

public function canShowTab()
{
return true;
}

public function isHidden()
{
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

class Mage_Adminhtml_Block_Customer_Address_Attribute_Edit_Tab_Options
extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
implements Mage_Adminhtml_Block_Widget_Tab_Interface
{

public function getTabLabel()
{
return Mage::helper('customer')->__('Manage Label / Options');
}

public function getTabTitle()
{
return Mage::helper('customer')->__('Properties');
}

public function canShowTab()
{
return true;
}

public function isHidden()
{
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

class Mage_Adminhtml_Block_Customer_Address_Attribute_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
{
public function __construct()
{
parent::__construct();
$this->setId('customer_address_attribute_tabs');
$this->setDestElementId('edit_form');
$this->setTitle(Mage::helper('customer')->__('Attribute Information'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* Magento
*
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @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)
*/

class Mage_Adminhtml_Block_Customer_Address_Attribute_Grid extends Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract
{
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/address_attribute_collection')
->addVisibleFilter();
$this->setCollection($collection);

return parent::_prepareCollection();
}

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

$this->addColumn('is_visible', [
'header' => Mage::helper('customer')->__('Visible on Frontend'),
'sortable' => true,
'index' => 'is_visible',
'align' => 'center',
'type' => 'options',
'options' => [
'1' => Mage::helper('customer')->__('Yes'),
'0' => Mage::helper('customer')->__('No')
]
]);

$this->addColumn('sort_order', array(
'header' => Mage::helper('customer')->__('Sort Order'),
'sortable' => true,
'index' => 'sort_order',
'align' => 'center'
));

return $this;
}
}
36 changes: 36 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Customer/Attribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Magento
*
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @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)
*/

class Mage_Adminhtml_Block_Customer_Attribute extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_controller = 'customer_attribute';
$this->_headerText = Mage::helper('customer')->__('Manage Customer Attributes');
$this->_addButtonLabel = Mage::helper('customer')->__('Add New Attribute');
parent::__construct();
}
}
Loading