Version Notes
Manage customer attributes and collect more information from customers.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Custom_Attributemanager |
Version | 0.0.6 |
Comparing to | |
See all releases |
Version 0.0.6
- app/code/community/Custom/Attributemanager/Block/Adminhtml/Customer/Edit/Tab/Account.php +207 -0
- app/code/community/Custom/Attributemanager/Block/Attributemanager.php +24 -0
- app/code/community/Custom/Attributemanager/Block/Edit.php +108 -0
- app/code/community/Custom/Attributemanager/Block/Edit/Form.php +11 -0
- app/code/community/Custom/Attributemanager/Block/Edit/Tab/Front.php +72 -0
- app/code/community/Custom/Attributemanager/Block/Edit/Tab/Main.php +270 -0
- app/code/community/Custom/Attributemanager/Block/Edit/Tab/Options.php +152 -0
- app/code/community/Custom/Attributemanager/Block/Edit/Tab/System.php +103 -0
- app/code/community/Custom/Attributemanager/Block/Edit/Tabs.php +42 -0
- app/code/community/Custom/Attributemanager/Block/Grid.php +164 -0
- app/code/community/Custom/Attributemanager/Helper/Data.php +4 -0
- app/code/community/Custom/Attributemanager/Model/Attributemanager.php +44 -0
- app/code/community/Custom/Attributemanager/controllers/IndexController.php +270 -0
- app/code/community/Custom/Attributemanager/etc/config.xml +93 -0
- app/design/adminhtml/default/default/layout/attributemanager.xml +33 -0
- app/design/adminhtml/default/default/template/attributemanager/grid.phtml +179 -0
- app/design/adminhtml/default/default/template/attributemanager/index.phtml +21 -0
- app/design/adminhtml/default/default/template/attributemanager/js.phtml +274 -0
- app/design/adminhtml/default/default/template/attributemanager/new/created.phtml +54 -0
- app/design/adminhtml/default/default/template/attributemanager/options.phtml +178 -0
- app/design/frontend/default/default/layout/attributemanager.xml +32 -0
- app/design/frontend/default/default/template/customer/form/edit.phtml +199 -0
- app/design/frontend/default/default/template/customer/form/register.phtml +271 -0
- app/design/frontend/default/default/template/persistent/customer/form/edit.phtml +201 -0
- app/design/frontend/default/default/template/persistent/customer/form/register.phtml +268 -0
- app/etc/modules/Custom_Attributemanager.xml +9 -0
- package.xml +22 -0
app/code/community/Custom/Attributemanager/Block/Adminhtml/Customer/Edit/Tab/Account.php
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Adminhtml_Customer_Edit_Tab_Account extends Mage_Adminhtml_Block_Customer_Edit_Tab_Account
|
3 |
+
{
|
4 |
+
public function initForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$form->setHtmlIdPrefix('_account');
|
8 |
+
$form->setFieldNameSuffix('account');
|
9 |
+
|
10 |
+
$customer = Mage::registry('current_customer');
|
11 |
+
|
12 |
+
/* @var $customerForm Mage_Customer_Model_Form */
|
13 |
+
$customerForm = Mage::getModel('customer/form');
|
14 |
+
$customerForm->setEntity($customer)
|
15 |
+
->setFormCode('adminhtml_customer')
|
16 |
+
->initDefaultValues();
|
17 |
+
|
18 |
+
$fieldset = $form->addFieldset('base_fieldset',
|
19 |
+
array('legend'=>Mage::helper('customer')->__('Account Information'))
|
20 |
+
);
|
21 |
+
|
22 |
+
$attributes = $customerForm->getAttributes();
|
23 |
+
|
24 |
+
foreach ($attributes as $attribute) {
|
25 |
+
$attribute->unsIsVisible();
|
26 |
+
}
|
27 |
+
$this->_setFieldset($attributes, $fieldset);
|
28 |
+
|
29 |
+
if ($customer->getId()) {
|
30 |
+
$form->getElement('website_id')->setDisabled('disabled');
|
31 |
+
$form->getElement('created_in')->setDisabled('disabled');
|
32 |
+
} else {
|
33 |
+
$fieldset->removeField('created_in');
|
34 |
+
}
|
35 |
+
|
36 |
+
if (Mage::app()->isSingleStoreMode()) {
|
37 |
+
$fieldset->removeField('website_id');
|
38 |
+
$fieldset->addField('website_id', 'hidden', array(
|
39 |
+
'name' => 'website_id'
|
40 |
+
));
|
41 |
+
$customer->setWebsiteId(Mage::app()->getStore(true)->getWebsiteId());
|
42 |
+
}
|
43 |
+
|
44 |
+
$customer_group_id = $customer->getGroupId();
|
45 |
+
|
46 |
+
$fieldsetcompany = $form->addFieldset('more_fieldset',
|
47 |
+
array('legend'=>Mage::helper('customer')->__('More Information'))
|
48 |
+
);
|
49 |
+
|
50 |
+
$js_arr = array();
|
51 |
+
foreach ($attributes as $attribute) {
|
52 |
+
|
53 |
+
if($attribute->getIsUserDefined()) {
|
54 |
+
// remove field from base fieldset
|
55 |
+
$fieldset->removeField($attribute->getAttributeCode());
|
56 |
+
|
57 |
+
// insert field in our custom fieldset
|
58 |
+
if($attribute->getFrontendInput() == 'boolean' || $attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'checkbox') {
|
59 |
+
|
60 |
+
$element = $fieldsetcompany->addField($attribute->getAttributeCode(), $attribute->getFrontendInput(), array(
|
61 |
+
'label' => $attribute->getFrontend()->getLabel(),
|
62 |
+
'required' => $attribute->getIsRequired(),
|
63 |
+
'name' => $attribute->getAttributeCode(),
|
64 |
+
'values' => $attribute->getFrontend()->getAttribute()->getSource()->getAllOptions()
|
65 |
+
));
|
66 |
+
|
67 |
+
} else {
|
68 |
+
|
69 |
+
$element = $fieldsetcompany->addField($attribute->getAttributeCode(), $attribute->getFrontendInput(), array(
|
70 |
+
'label' => $attribute->getFrontend()->getLabel(),
|
71 |
+
'required' => $attribute->getIsRequired(),
|
72 |
+
'name' => $attribute->getAttributeCode()
|
73 |
+
))
|
74 |
+
->setEntityAttribute($attribute);
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
if ($attribute->getFrontendInput() == 'date') {
|
79 |
+
$element->setImage($this->getSkinUrl('images/grid-cal.gif'));
|
80 |
+
$element->setFormat(Mage::app()->getLocale()->getDateFormatWithLongYear());
|
81 |
+
}
|
82 |
+
if($attribute->getIsRequired())
|
83 |
+
$js_arr[] = $attribute->getAttributeCode();
|
84 |
+
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
$prefix = $form->getHtmlIdPrefix();
|
89 |
+
$total_elements = count($js_arr);
|
90 |
+
$add_class_js_script = '';
|
91 |
+
$remove_class_js_script = '';
|
92 |
+
for($j=0; $j<$total_elements; $j++) {
|
93 |
+
$add_class_js_script .= " $('{$prefix}". $js_arr[$j] ."').addClassName('required-entry') ;";
|
94 |
+
$remove_class_js_script .= " $('{$prefix}". $js_arr[$j] ."').removeClassName('required-entry') ;";
|
95 |
+
}
|
96 |
+
|
97 |
+
$customer_group = $form->getElement('group_id');
|
98 |
+
|
99 |
+
if ($customer->getId()) {
|
100 |
+
if (!$customer->isReadonly()) {
|
101 |
+
// add password management fieldset
|
102 |
+
$newFieldset = $form->addFieldset(
|
103 |
+
'password_fieldset',
|
104 |
+
array('legend'=>Mage::helper('customer')->__('Password Management'))
|
105 |
+
);
|
106 |
+
// New customer password
|
107 |
+
$field = $newFieldset->addField('new_password', 'text',
|
108 |
+
array(
|
109 |
+
'label' => Mage::helper('customer')->__('New Password'),
|
110 |
+
'name' => 'new_password',
|
111 |
+
'class' => 'validate-new-password'
|
112 |
+
)
|
113 |
+
);
|
114 |
+
$field->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_newpass'));
|
115 |
+
|
116 |
+
// prepare customer confirmation control (only for existing customers)
|
117 |
+
$confirmationKey = $customer->getConfirmation();
|
118 |
+
if ($confirmationKey || $customer->isConfirmationRequired()) {
|
119 |
+
$confirmationAttribute = $customer->getAttribute('confirmation');
|
120 |
+
if (!$confirmationKey) {
|
121 |
+
$confirmationKey = $customer->getRandomConfirmationKey();
|
122 |
+
}
|
123 |
+
$element = $fieldset->addField('confirmation', 'select', array(
|
124 |
+
'name' => 'confirmation',
|
125 |
+
'label' => Mage::helper('customer')->__($confirmationAttribute->getFrontendLabel()),
|
126 |
+
))->setEntityAttribute($confirmationAttribute)
|
127 |
+
->setValues(array('' => 'Confirmed', $confirmationKey => 'Not confirmed'));
|
128 |
+
|
129 |
+
// prepare send welcome email checkbox, if customer is not confirmed
|
130 |
+
// no need to add it, if website id is empty
|
131 |
+
if ($customer->getConfirmation() && $customer->getWebsiteId()) {
|
132 |
+
$fieldset->addField('sendemail', 'checkbox', array(
|
133 |
+
'name' => 'sendemail',
|
134 |
+
'label' => Mage::helper('customer')->__('Send Welcome Email after Confirmation')
|
135 |
+
));
|
136 |
+
$customer->setData('sendemail', '1');
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
} else {
|
141 |
+
$newFieldset = $form->addFieldset(
|
142 |
+
'password_fieldset',
|
143 |
+
array('legend'=>Mage::helper('customer')->__('Password Management'))
|
144 |
+
);
|
145 |
+
$field = $newFieldset->addField('password', 'text',
|
146 |
+
array(
|
147 |
+
'label' => Mage::helper('customer')->__('Password'),
|
148 |
+
'class' => 'input-text required-entry validate-password',
|
149 |
+
'name' => 'password',
|
150 |
+
'required' => true
|
151 |
+
)
|
152 |
+
);
|
153 |
+
$field->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_newpass'));
|
154 |
+
|
155 |
+
// prepare send welcome email checkbox
|
156 |
+
$fieldset->addField('sendemail', 'checkbox', array(
|
157 |
+
'label' => Mage::helper('customer')->__('Send Welcome Email'),
|
158 |
+
'name' => 'sendemail',
|
159 |
+
'id' => 'sendemail',
|
160 |
+
));
|
161 |
+
$customer->setData('sendemail', '1');
|
162 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
163 |
+
$fieldset->addField('sendemail_store_id', 'select', array(
|
164 |
+
'label' => $this->helper('customer')->__('Send From'),
|
165 |
+
'name' => 'sendemail_store_id',
|
166 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()
|
167 |
+
));
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
// make sendemail and sendmail_store_id disabled, if website_id has empty value
|
172 |
+
$isSingleMode = Mage::app()->isSingleStoreMode();
|
173 |
+
$sendEmailId = $isSingleMode ? 'sendemail' : 'sendemail_store_id';
|
174 |
+
$sendEmail = $form->getElement($sendEmailId);
|
175 |
+
|
176 |
+
$prefix = $form->getHtmlIdPrefix();
|
177 |
+
if ($sendEmail) {
|
178 |
+
$sendEmail->setAfterElementHtml(
|
179 |
+
'<script type="text/javascript">'
|
180 |
+
. "
|
181 |
+
$('{$prefix}website_id').disableSendemail = function() {
|
182 |
+
$('{$prefix}sendemail').disabled = ('' == this.value || '0' == this.value);".
|
183 |
+
($isSingleMode ? "" : "$('{$prefix}sendemail_store_id').disabled = ('' == this.value || '0' == this.value);")
|
184 |
+
."}.bind($('{$prefix}website_id'));
|
185 |
+
Event.observe('{$prefix}website_id', 'change', $('{$prefix}website_id').disableSendemail);
|
186 |
+
$('{$prefix}website_id').disableSendemail();
|
187 |
+
"
|
188 |
+
. '</script>'
|
189 |
+
);
|
190 |
+
}
|
191 |
+
|
192 |
+
if ($customer->isReadonly()) {
|
193 |
+
foreach ($customer->getAttributes() as $attribute) {
|
194 |
+
$element = $form->getElement($attribute->getAttributeCode());
|
195 |
+
if ($element) {
|
196 |
+
$element->setReadonly(true, true);
|
197 |
+
}
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
$form->setValues($customer->getData());
|
202 |
+
$this->setForm($form);
|
203 |
+
|
204 |
+
return $this;
|
205 |
+
}
|
206 |
+
|
207 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Attributemanager.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Attributemanager extends Mage_Adminhtml_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function _construct()
|
10 |
+
{
|
11 |
+
parent::_construct();
|
12 |
+
$this->setTemplate('attributemanager/index.phtml');
|
13 |
+
$this->getAttributemanager();
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getAttributemanager()
|
17 |
+
{
|
18 |
+
if (!$this->hasData('attributemanager/index')) {
|
19 |
+
$this->setData('attributemanager/index', Mage::registry('attributemanager/index'));
|
20 |
+
}
|
21 |
+
|
22 |
+
return $this->getData('attributemanager/index');
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Edit.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
3 |
+
{
|
4 |
+
protected function _prepareLayout()
|
5 |
+
{
|
6 |
+
$this->setChild('form', $this->getLayout()->createBlock($this->_blockGroup . '/' . $this->_mode . '_form'));
|
7 |
+
return parent::_prepareLayout();
|
8 |
+
}
|
9 |
+
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
$this->_objectId = 'attribute_id';
|
13 |
+
$this->_controller = 'index';
|
14 |
+
$this->_blockGroup = 'attributemanager';
|
15 |
+
|
16 |
+
parent::__construct();
|
17 |
+
|
18 |
+
//$this->_removeButton('back');
|
19 |
+
|
20 |
+
$this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/index/customer') . '\')');
|
21 |
+
|
22 |
+
if($this->getRequest()->getParam('popup')) {
|
23 |
+
$this->_removeButton('back');
|
24 |
+
$this->_addButton(
|
25 |
+
'close',
|
26 |
+
array(
|
27 |
+
'label' => Mage::helper('catalog')->__('Close Window'),
|
28 |
+
'class' => 'cancel',
|
29 |
+
'onclick' => 'window.close()',
|
30 |
+
'level' => -1
|
31 |
+
)
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Attribute'));
|
36 |
+
/*$this->_addButton(
|
37 |
+
'save_and_edit_button',
|
38 |
+
array(
|
39 |
+
'label' => Mage::helper('catalog')->__('Save And Continue Edit'),
|
40 |
+
'onclick' => 'saveAndContinueEdit()',
|
41 |
+
'class' => 'save'
|
42 |
+
),
|
43 |
+
100
|
44 |
+
);*/
|
45 |
+
|
46 |
+
if (! Mage::registry('attributemanager_data')->getIsUserDefined()) {
|
47 |
+
$this->_removeButton('delete');
|
48 |
+
} else {
|
49 |
+
$this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Attribute'));
|
50 |
+
$this->_updateButton('delete', 'onclick', "deleteConfirm(
|
51 |
+
'".Mage::helper('adminhtml')->__('Are you sure you want to do this?')."',
|
52 |
+
'".$this->getUrl('*/*/delete/type/'.$this->getRequest()->getParam('type').'/attribute_id/'.$this->getRequest()->getParam('attribute_id')
|
53 |
+
)."')");
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getHeaderText()
|
58 |
+
{
|
59 |
+
/* switch (){
|
60 |
+
case 'catalog_category':
|
61 |
+
$type="Category";
|
62 |
+
break;
|
63 |
+
case 'customer':
|
64 |
+
$type="Customer";
|
65 |
+
break;
|
66 |
+
case 'customer_address':
|
67 |
+
$type="Customer address";
|
68 |
+
break;
|
69 |
+
}*/
|
70 |
+
|
71 |
+
$types = array(
|
72 |
+
'catalog_category' => 'Category',
|
73 |
+
'customer' => 'Customer',
|
74 |
+
'customer_address' => 'Customer address',
|
75 |
+
'order' => 'Order',
|
76 |
+
'order_address' => 'Order address',
|
77 |
+
'order_item' => 'Order item',
|
78 |
+
'order_payment' => 'Order payment',
|
79 |
+
'order_status_history' => 'Order status history',
|
80 |
+
'invoice' => 'Invoice',
|
81 |
+
'invoice_item' => 'Invoice item',
|
82 |
+
'invoice_comment' => 'Invoice comment',
|
83 |
+
);
|
84 |
+
$t = $this->getRequest()->getParam('type');
|
85 |
+
if(!isset($types[$t])) {
|
86 |
+
$type = 'Category';
|
87 |
+
} else {
|
88 |
+
$type = $types[$t];
|
89 |
+
}
|
90 |
+
if (Mage::registry('attributemanager_data')->getId()) {
|
91 |
+
return Mage::helper('attributemanager')->__('Edit %s Attribute "%s"', $type, $this->htmlEscape(Mage::registry('attributemanager_data')->getFrontendLabel()));
|
92 |
+
}
|
93 |
+
else {
|
94 |
+
return Mage::helper('attributemanager')->__('New %s Attribute', $type);
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
public function getValidationUrl()
|
100 |
+
{
|
101 |
+
return $this->getUrl('*/*/validate', array('_current'=>true));
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getSaveUrl()
|
105 |
+
{
|
106 |
+
return $this->getUrl('*/'.$this->_controller.'/save', array('_current'=>true, 'back'=> '*/'.$this->_controller.'/customer'));
|
107 |
+
}
|
108 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Edit/Form.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
|
7 |
+
$form->setUseContainer(true);
|
8 |
+
$this->setForm($form);
|
9 |
+
return parent::_prepareForm();
|
10 |
+
}
|
11 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Edit/Tab/Front.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Edit_Tab_Front extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$model = Mage::registry('attributemanager_data');
|
7 |
+
|
8 |
+
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
|
9 |
+
|
10 |
+
$fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('catalog')->__('Frontend Properties')));
|
11 |
+
|
12 |
+
$yesno = array(
|
13 |
+
array(
|
14 |
+
'value' => 0,
|
15 |
+
'label' => Mage::helper('catalog')->__('No')
|
16 |
+
),
|
17 |
+
array(
|
18 |
+
'value' => 1,
|
19 |
+
'label' => Mage::helper('catalog')->__('Yes')
|
20 |
+
));
|
21 |
+
|
22 |
+
|
23 |
+
$fieldset->addField('is_searchable', 'select', array(
|
24 |
+
'name' => 'is_searchable',
|
25 |
+
'label' => Mage::helper('catalog')->__('Use in quick search'),
|
26 |
+
'title' => Mage::helper('catalog')->__('Use in quick search'),
|
27 |
+
'values' => $yesno,
|
28 |
+
));
|
29 |
+
|
30 |
+
$fieldset->addField('is_visible_in_advanced_search', 'select', array(
|
31 |
+
'name' => 'is_visible_in_advanced_search',
|
32 |
+
'label' => Mage::helper('catalog')->__('Use in advanced search'),
|
33 |
+
'title' => Mage::helper('catalog')->__('Use in advanced search'),
|
34 |
+
'values' => $yesno,
|
35 |
+
));
|
36 |
+
|
37 |
+
$fieldset->addField('is_comparable', 'select', array(
|
38 |
+
'name' => 'is_comparable',
|
39 |
+
'label' => Mage::helper('catalog')->__('Comparable on Front-end'),
|
40 |
+
'title' => Mage::helper('catalog')->__('Comparable on Front-end'),
|
41 |
+
'values' => $yesno,
|
42 |
+
));
|
43 |
+
|
44 |
+
|
45 |
+
$fieldset->addField('is_filterable', 'select', array(
|
46 |
+
'name' => 'is_filterable',
|
47 |
+
'label' => Mage::helper('catalog')->__("Use In Layered Navigation<br/>(Can be used only with catalog input type 'Dropdown')"),
|
48 |
+
'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown'),
|
49 |
+
'values' => array(
|
50 |
+
array('value' => '0', 'label' => Mage::helper('catalog')->__('No')),
|
51 |
+
array('value' => '1', 'label' => Mage::helper('catalog')->__('Filterable (with results)')),
|
52 |
+
array('value' => '2', 'label' => Mage::helper('catalog')->__('Filterable (no results)')),
|
53 |
+
),
|
54 |
+
));
|
55 |
+
|
56 |
+
// if ($model->getIsUserDefined() || !$model->getId()) {
|
57 |
+
$fieldset->addField('is_visible_on_front', 'select', array(
|
58 |
+
'name' => 'is_visible_on_front',
|
59 |
+
'label' => Mage::helper('catalog')->__('Visible on Catalog Pages on Front-end'),
|
60 |
+
'title' => Mage::helper('catalog')->__('Visible on Catalog Pages on Front-end'),
|
61 |
+
'values' => $yesno,
|
62 |
+
));
|
63 |
+
// }
|
64 |
+
|
65 |
+
$form->setValues($model->getData());
|
66 |
+
|
67 |
+
$this->setForm($form);
|
68 |
+
|
69 |
+
return parent::_prepareForm();
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Edit/Tab/Main.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$model = Mage::registry('attributemanager_data');
|
8 |
+
|
9 |
+
$form = new Varien_Data_Form(array(
|
10 |
+
'id' => 'edit_form',
|
11 |
+
'action' => $this->getData('action'),
|
12 |
+
'method' => 'post'
|
13 |
+
));
|
14 |
+
|
15 |
+
$fieldset = $form->addFieldset('base_fieldset',
|
16 |
+
array('legend'=>Mage::helper('catalog')->__('Attribute Properties'))
|
17 |
+
);
|
18 |
+
if ($model->getId()) {
|
19 |
+
$fieldset->addField('attribute_id', 'hidden', array(
|
20 |
+
'name' => 'attribute_id',
|
21 |
+
));
|
22 |
+
}
|
23 |
+
|
24 |
+
$this->_addElementTypes($fieldset);
|
25 |
+
|
26 |
+
$yesno = array(
|
27 |
+
array(
|
28 |
+
'value' => 0,
|
29 |
+
'label' => Mage::helper('catalog')->__('No')
|
30 |
+
),
|
31 |
+
array(
|
32 |
+
'value' => 1,
|
33 |
+
'label' => Mage::helper('catalog')->__('Yes')
|
34 |
+
));
|
35 |
+
|
36 |
+
$fieldset->addField('attribute_code', 'text', array(
|
37 |
+
'name' => 'attribute_code',
|
38 |
+
'label' => Mage::helper('catalog')->__('Attribute Code'),
|
39 |
+
'title' => Mage::helper('catalog')->__('Attribute Code'),
|
40 |
+
'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'),
|
41 |
+
'class' => 'validate-code',
|
42 |
+
'required' => true,
|
43 |
+
));
|
44 |
+
|
45 |
+
$scopes = array(
|
46 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('catalog')->__('Store View'),
|
47 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('catalog')->__('Website'),
|
48 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'),
|
49 |
+
);
|
50 |
+
|
51 |
+
if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') {
|
52 |
+
unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]);
|
53 |
+
}
|
54 |
+
|
55 |
+
/* $fieldset->addField('is_global', 'select', array(
|
56 |
+
'name' => 'is_global',
|
57 |
+
'label' => Mage::helper('catalog')->__('Scope'),
|
58 |
+
'title' => Mage::helper('catalog')->__('Scope'),
|
59 |
+
'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'),
|
60 |
+
'values'=> $scopes
|
61 |
+
));
|
62 |
+
*/
|
63 |
+
$inputTypes = array(
|
64 |
+
array(
|
65 |
+
'value' => 'text',
|
66 |
+
'label' => Mage::helper('catalog')->__('Text Field')
|
67 |
+
),
|
68 |
+
array(
|
69 |
+
'value' => 'textarea',
|
70 |
+
'label' => Mage::helper('catalog')->__('Text Area')
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'value' => 'date',
|
74 |
+
'label' => Mage::helper('catalog')->__('Date')
|
75 |
+
),
|
76 |
+
array(
|
77 |
+
'value' => 'boolean',
|
78 |
+
'label' => Mage::helper('catalog')->__('Yes/No')
|
79 |
+
),
|
80 |
+
array(
|
81 |
+
'value' => 'multiselect',
|
82 |
+
'label' => Mage::helper('catalog')->__('Multiple Select')
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'value' => 'select',
|
86 |
+
'label' => Mage::helper('catalog')->__('Dropdown')
|
87 |
+
),
|
88 |
+
);
|
89 |
+
if($this->getRequest ()->getParam ( 'type' )==="catalog_category"){
|
90 |
+
$inputTypes[]= array(
|
91 |
+
'value' => 'image',
|
92 |
+
'label' => Mage::helper('catalog')->__('Image')
|
93 |
+
|
94 |
+
);
|
95 |
+
}
|
96 |
+
|
97 |
+
$response = new Varien_Object();
|
98 |
+
$response->setTypes(array());
|
99 |
+
//Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response));
|
100 |
+
|
101 |
+
$_disabledTypes = array();
|
102 |
+
$_hiddenFields = array();
|
103 |
+
foreach ($response->getTypes() as $type) {
|
104 |
+
$inputTypes[] = $type;
|
105 |
+
if (isset($type['hide_fields'])) {
|
106 |
+
$_hiddenFields[$type['value']] = $type['hide_fields'];
|
107 |
+
}
|
108 |
+
if (isset($type['disabled_types'])) {
|
109 |
+
$_disabledTypes[$type['value']] = $type['disabled_types'];
|
110 |
+
}
|
111 |
+
}
|
112 |
+
Mage::register('attribute_type_hidden_fields', $_hiddenFields);
|
113 |
+
Mage::register('attribute_type_disabled_types', $_disabledTypes);
|
114 |
+
|
115 |
+
|
116 |
+
$fieldset->addField('frontend_input', 'select', array(
|
117 |
+
'name' => 'frontend_input',
|
118 |
+
'label' => Mage::helper('catalog')->__('Input Type'),
|
119 |
+
'title' => Mage::helper('catalog')->__('Input Type'),
|
120 |
+
'value' => 'text',
|
121 |
+
'values'=> $inputTypes
|
122 |
+
));
|
123 |
+
|
124 |
+
$fieldset->addField('entity_type_id', 'hidden', array(
|
125 |
+
'name' => 'entity_type_id',
|
126 |
+
'value' => Mage::getModel('eav/entity')->setType($this->getRequest ()->getParam ( 'type' ))->getTypeId()
|
127 |
+
));
|
128 |
+
|
129 |
+
|
130 |
+
|
131 |
+
$fieldset->addField('is_user_defined', 'hidden', array(
|
132 |
+
'name' => 'is_user_defined',
|
133 |
+
'value' => 1
|
134 |
+
));
|
135 |
+
|
136 |
+
$fieldset->addField('attribute_set_id', 'hidden', array(
|
137 |
+
'name' => 'attribute_set_id',
|
138 |
+
'value' => Mage::getModel('eav/entity')->setType($this->getRequest ()->getParam ( 'type' ))->getTypeId()
|
139 |
+
));
|
140 |
+
|
141 |
+
$fieldset->addField('attribute_group_id', 'hidden', array(
|
142 |
+
'name' => 'attribute_group_id',
|
143 |
+
'value' => Mage::getModel('eav/entity')->setType($this->getRequest ()->getParam ( 'type' ))->getTypeId()
|
144 |
+
));
|
145 |
+
|
146 |
+
|
147 |
+
/*******************************************************/
|
148 |
+
/* $fieldset->addField('is_unique', 'select', array(
|
149 |
+
'name' => 'is_unique',
|
150 |
+
'label' => Mage::helper('catalog')->__('Unique Value'),
|
151 |
+
'title' => Mage::helper('catalog')->__('Unique Value (not shared with other products)'),
|
152 |
+
'note' => Mage::helper('catalog')->__('Not shared with other products'),
|
153 |
+
'values' => $yesno,
|
154 |
+
));
|
155 |
+
*/
|
156 |
+
$fieldset->addField('is_required', 'select', array(
|
157 |
+
'name' => 'is_required',
|
158 |
+
'label' => Mage::helper('catalog')->__('Values Required'),
|
159 |
+
'title' => Mage::helper('catalog')->__('Values Required'),
|
160 |
+
'values' => $yesno,
|
161 |
+
));
|
162 |
+
|
163 |
+
$fieldset->addField('frontend_class', 'select', array(
|
164 |
+
'name' => 'frontend_class',
|
165 |
+
'label' => Mage::helper('catalog')->__('Input Validation'),
|
166 |
+
'title' => Mage::helper('catalog')->__('Input Validation'),
|
167 |
+
'values'=> array(
|
168 |
+
array(
|
169 |
+
'value' => '',
|
170 |
+
'label' => Mage::helper('catalog')->__('None')
|
171 |
+
),
|
172 |
+
array(
|
173 |
+
'value' => 'validate-number',
|
174 |
+
'label' => Mage::helper('catalog')->__('Decimal Number')
|
175 |
+
),
|
176 |
+
array(
|
177 |
+
'value' => 'validate-digits',
|
178 |
+
'label' => Mage::helper('catalog')->__('Integer Number')
|
179 |
+
),
|
180 |
+
array(
|
181 |
+
'value' => 'validate-email',
|
182 |
+
'label' => Mage::helper('catalog')->__('Email')
|
183 |
+
),
|
184 |
+
array(
|
185 |
+
'value' => 'validate-url',
|
186 |
+
'label' => Mage::helper('catalog')->__('Url')
|
187 |
+
),
|
188 |
+
array(
|
189 |
+
'value' => 'validate-alpha',
|
190 |
+
'label' => Mage::helper('catalog')->__('Letters')
|
191 |
+
),
|
192 |
+
array(
|
193 |
+
'value' => 'validate-alphanum',
|
194 |
+
'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)')
|
195 |
+
),
|
196 |
+
)
|
197 |
+
));
|
198 |
+
|
199 |
+
// -----
|
200 |
+
|
201 |
+
|
202 |
+
// frontend properties fieldset
|
203 |
+
$fieldset = $form->addFieldset('front_fieldset',
|
204 |
+
array('legend'=>Mage::helper('catalog')->__('Frontend Properties')));
|
205 |
+
|
206 |
+
|
207 |
+
|
208 |
+
/*$fieldset->addField('position', 'text', array(
|
209 |
+
'name' => 'position',
|
210 |
+
'label' => Mage::helper('catalog')->__('Position'),
|
211 |
+
'title' => Mage::helper('catalog')->__('Position In Layered Navigation'),
|
212 |
+
'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'),
|
213 |
+
'class' => 'validate-digits',
|
214 |
+
));*/
|
215 |
+
|
216 |
+
/*if ($model->getIsUserDefined() || !$model->getId()) {
|
217 |
+
$fieldset->addField('is_visible_on_front', 'select', array(
|
218 |
+
'name' => 'is_visible_on_front',
|
219 |
+
'label' => Mage::helper('catalog')->__('Visible on Catalog Pages on Front-end'),
|
220 |
+
'title' => Mage::helper('catalog')->__('Visible on Catalog Pages on Front-end'),
|
221 |
+
'values' => $yesno,
|
222 |
+
));
|
223 |
+
}*/
|
224 |
+
|
225 |
+
/* $fieldset->addField('show_in_frontend', 'select', array(
|
226 |
+
'name' => 'show_in_frontend',
|
227 |
+
'label' => Mage::helper('catalog')->__('Show in Frontend'),
|
228 |
+
'title' => Mage::helper('catalog')->__('Show in Frontend'),
|
229 |
+
'values' => $yesno,
|
230 |
+
));
|
231 |
+
*/
|
232 |
+
$fieldset->addField('sort_order', 'text', array(
|
233 |
+
'name' => 'sort_order',
|
234 |
+
'label' => Mage::helper('catalog')->__('Order'),
|
235 |
+
'title' => Mage::helper('catalog')->__('Order in form'),
|
236 |
+
'note' => Mage::helper('catalog')->__('order of attribute in form edit/create. Leave blank for form bottom.'),
|
237 |
+
'class' => 'validate-digits',
|
238 |
+
'value' => $model->getSortOrder()
|
239 |
+
));
|
240 |
+
|
241 |
+
|
242 |
+
if ($model->getId()) {
|
243 |
+
$form->getElement('attribute_code')->setDisabled(1);
|
244 |
+
$form->getElement('frontend_input')->setDisabled(1);
|
245 |
+
|
246 |
+
if (isset($disableAttributeFields[$model->getAttributeCode()])) {
|
247 |
+
foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) {
|
248 |
+
$form->getElement($field)->setDisabled(1);
|
249 |
+
}
|
250 |
+
}
|
251 |
+
}
|
252 |
+
/* if (!$model->getIsUserDefined() && $model->getId()) {
|
253 |
+
$form->getElement('is_unique')->setDisabled(1);
|
254 |
+
}
|
255 |
+
*/
|
256 |
+
//var_dump($model->getData());exit;
|
257 |
+
$form->addValues($model->getData());
|
258 |
+
|
259 |
+
$this->setForm($form);
|
260 |
+
|
261 |
+
return parent::_prepareForm();
|
262 |
+
}
|
263 |
+
|
264 |
+
protected function _getAdditionalElementTypes()
|
265 |
+
{
|
266 |
+
return array(
|
267 |
+
'apply' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_apply')
|
268 |
+
);
|
269 |
+
}
|
270 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Edit/Tab/Options.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Edit_Tab_Options extends Mage_Adminhtml_Block_Widget
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setTemplate('attributemanager/options.phtml');
|
8 |
+
}
|
9 |
+
|
10 |
+
protected function _prepareLayout()
|
11 |
+
{
|
12 |
+
$this->setChild('delete_button',
|
13 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
14 |
+
->setData(array(
|
15 |
+
'label' => Mage::helper('catalog')->__('Delete'),
|
16 |
+
'class' => 'delete delete-option'
|
17 |
+
)));
|
18 |
+
|
19 |
+
$this->setChild('add_button',
|
20 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
21 |
+
->setData(array(
|
22 |
+
'label' => Mage::helper('catalog')->__('Add Option'),
|
23 |
+
'class' => 'add',
|
24 |
+
'id' => 'add_new_option_button'
|
25 |
+
)));
|
26 |
+
return parent::_prepareLayout();
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getDeleteButtonHtml()
|
30 |
+
{
|
31 |
+
return $this->getChildHtml('delete_button');
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getAddNewButtonHtml()
|
35 |
+
{
|
36 |
+
return $this->getChildHtml('add_button');
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getStores()
|
40 |
+
{
|
41 |
+
$stores = $this->getData('stores');
|
42 |
+
if (is_null($stores)) {
|
43 |
+
$stores = Mage::getModel('core/store')
|
44 |
+
->getResourceCollection()
|
45 |
+
->setLoadDefault(true)
|
46 |
+
->load();
|
47 |
+
$this->setData('stores', $stores);
|
48 |
+
}
|
49 |
+
return $stores;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getOptionValues()
|
53 |
+
{
|
54 |
+
$attributeType = $this->getAttributeObject()->getFrontendInput();
|
55 |
+
$defaultValues = $this->getAttributeObject()->getDefaultValue();
|
56 |
+
if ($attributeType == 'select' || $attributeType == 'multiselect') {
|
57 |
+
$defaultValues = explode(',', $defaultValues);
|
58 |
+
} else {
|
59 |
+
$defaultValues = array();
|
60 |
+
}
|
61 |
+
|
62 |
+
switch ($attributeType) {
|
63 |
+
case 'select':
|
64 |
+
$inputType = 'radio';
|
65 |
+
break;
|
66 |
+
case 'multiselect':
|
67 |
+
$inputType = 'checkbox';
|
68 |
+
break;
|
69 |
+
default:
|
70 |
+
$inputType = '';
|
71 |
+
break;
|
72 |
+
}
|
73 |
+
|
74 |
+
$values = $this->getData('option_values');
|
75 |
+
if (is_null($values)) {
|
76 |
+
$values = array();
|
77 |
+
$optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
78 |
+
->setAttributeFilter($this->getAttributeObject()->getId())
|
79 |
+
->setPositionOrder('desc', true)
|
80 |
+
->load();
|
81 |
+
|
82 |
+
foreach ($optionCollection as $option) {
|
83 |
+
$value = array();
|
84 |
+
if (in_array($option->getId(), $defaultValues)) {
|
85 |
+
$value['checked'] = 'checked="checked"';
|
86 |
+
} else {
|
87 |
+
$value['checked'] = '';
|
88 |
+
}
|
89 |
+
|
90 |
+
$value['intype'] = $inputType;
|
91 |
+
$value['id'] = $option->getId();
|
92 |
+
$value['sort_order'] = $option->getSortOrder();
|
93 |
+
foreach ($this->getStores() as $store) {
|
94 |
+
$storeValues = $this->getStoreOptionValues($store->getId());
|
95 |
+
if (isset($storeValues[$option->getId()])) {
|
96 |
+
$value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
|
97 |
+
}
|
98 |
+
else {
|
99 |
+
$value['store'.$store->getId()] = '';
|
100 |
+
}
|
101 |
+
}
|
102 |
+
$values[] = new Varien_Object($value);
|
103 |
+
}
|
104 |
+
$this->setData('option_values', $values);
|
105 |
+
}
|
106 |
+
|
107 |
+
return $values;
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getLabelValues()
|
111 |
+
{
|
112 |
+
$values = array();
|
113 |
+
$values[0] = $this->getAttributeObject()->getFrontend()->getLabel();
|
114 |
+
// it can be array and cause bug
|
115 |
+
$frontendLabel = $this->getAttributeObject()->getFrontend()->getLabel();
|
116 |
+
if (is_array($frontendLabel)) {
|
117 |
+
$frontendLabel = array_shift($frontendLabel);
|
118 |
+
}
|
119 |
+
$translations = Mage::getModel('core/translate_string')
|
120 |
+
->load(Mage_Catalog_Model_Entity_Attribute::MODULE_NAME.Mage_Core_Model_Translate::SCOPE_SEPARATOR.$frontendLabel)
|
121 |
+
->getStoreTranslations();
|
122 |
+
foreach ($this->getStores() as $store) {
|
123 |
+
if ($store->getId() != 0) {
|
124 |
+
$values[$store->getId()] = isset($translations[$store->getId()]) ? $translations[$store->getId()] : '';
|
125 |
+
}
|
126 |
+
}
|
127 |
+
return $values;
|
128 |
+
}
|
129 |
+
|
130 |
+
public function getStoreOptionValues($storeId)
|
131 |
+
{
|
132 |
+
$values = $this->getData('store_option_values_'.$storeId);
|
133 |
+
if (is_null($values)) {
|
134 |
+
$values = array();
|
135 |
+
$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
136 |
+
->setAttributeFilter($this->getAttributeObject()->getId())
|
137 |
+
->setStoreFilter($storeId, false)
|
138 |
+
->load();
|
139 |
+
foreach ($valuesCollection as $item) {
|
140 |
+
$values[$item->getId()] = $item->getValue();
|
141 |
+
}
|
142 |
+
$this->setData('store_option_values_'.$storeId, $values);
|
143 |
+
}
|
144 |
+
return $values;
|
145 |
+
}
|
146 |
+
|
147 |
+
public function getAttributeObject()
|
148 |
+
{
|
149 |
+
return Mage::registry('attributemanager_data');
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Edit/Tab/System.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Pol_Attributemanager_Block_Edit_Tab_System extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$model = Mage::registry('entity_attribute');
|
8 |
+
|
9 |
+
$form = new Varien_Data_Form();
|
10 |
+
$fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('catalog')->__('System Properties')));
|
11 |
+
|
12 |
+
if ($model->getAttributeId()) {
|
13 |
+
$fieldset->addField('attribute_id', 'hidden', array(
|
14 |
+
'name' => 'attribute_id',
|
15 |
+
));
|
16 |
+
}
|
17 |
+
|
18 |
+
$yesno = array(
|
19 |
+
array(
|
20 |
+
'value' => 0,
|
21 |
+
'label' => Mage::helper('catalog')->__('No')
|
22 |
+
),
|
23 |
+
array(
|
24 |
+
'value' => 1,
|
25 |
+
'label' => Mage::helper('catalog')->__('Yes')
|
26 |
+
));
|
27 |
+
|
28 |
+
/*$fieldset->addField('attribute_model', 'text', array(
|
29 |
+
'name' => 'attribute_model',
|
30 |
+
'label' => Mage::helper('catalog')->__('Attribute Model'),
|
31 |
+
'title' => Mage::helper('catalog')->__('Attribute Model'),
|
32 |
+
));
|
33 |
+
|
34 |
+
$fieldset->addField('backend_model', 'text', array(
|
35 |
+
'name' => 'backend_model',
|
36 |
+
'label' => Mage::helper('catalog')->__('Backend Model'),
|
37 |
+
'title' => Mage::helper('catalog')->__('Backend Model'),
|
38 |
+
));*/
|
39 |
+
|
40 |
+
$fieldset->addField('backend_type', 'select', array(
|
41 |
+
'name' => 'backend_type',
|
42 |
+
'label' => Mage::helper('catalog')->__('Data Type for Saving in Database'),
|
43 |
+
'title' => Mage::helper('catalog')->__('Data Type for Saving in Database'),
|
44 |
+
'options' => array(
|
45 |
+
'text' => Mage::helper('catalog')->__('Text'),
|
46 |
+
'varchar' => Mage::helper('catalog')->__('Varchar'),
|
47 |
+
'static' => Mage::helper('catalog')->__('Static'),
|
48 |
+
'datetime' => Mage::helper('catalog')->__('Datetime'),
|
49 |
+
'decimal' => Mage::helper('catalog')->__('Decimal'),
|
50 |
+
'int' => Mage::helper('catalog')->__('Integer'),
|
51 |
+
),
|
52 |
+
));
|
53 |
+
|
54 |
+
/*$fieldset->addField('backend_table', 'text', array(
|
55 |
+
'name' => 'backend_table',
|
56 |
+
'label' => Mage::helper('catalog')->__('Backend Table'),
|
57 |
+
'title' => Mage::helper('catalog')->__('Backend Table Title'),
|
58 |
+
));
|
59 |
+
|
60 |
+
$fieldset->addField('frontend_model', 'text', array(
|
61 |
+
'name' => 'frontend_model',
|
62 |
+
'label' => Mage::helper('catalog')->__('Frontend Model'),
|
63 |
+
'title' => Mage::helper('catalog')->__('Frontend Model'),
|
64 |
+
));*/
|
65 |
+
|
66 |
+
/*$fieldset->addField('is_visible', 'select', array(
|
67 |
+
'name' => 'is_visible',
|
68 |
+
'label' => Mage::helper('catalog')->__('Visible'),
|
69 |
+
'title' => Mage::helper('catalog')->__('Visible'),
|
70 |
+
'values' => $yesno,
|
71 |
+
));*/
|
72 |
+
|
73 |
+
/*$fieldset->addField('source_model', 'text', array(
|
74 |
+
'name' => 'source_model',
|
75 |
+
'label' => Mage::helper('catalog')->__('Source Model'),
|
76 |
+
'title' => Mage::helper('catalog')->__('Source Model'),
|
77 |
+
));*/
|
78 |
+
|
79 |
+
$fieldset->addField('is_global', 'select', array(
|
80 |
+
'name' => 'is_global',
|
81 |
+
'label' => Mage::helper('catalog')->__('Globally Editable'),
|
82 |
+
'title' => Mage::helper('catalog')->__('Globally Editable'),
|
83 |
+
'values'=> $yesno,
|
84 |
+
));
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
$form->setValues($model->getData());
|
89 |
+
|
90 |
+
if ($model->getAttributeId()) {
|
91 |
+
$form->getElement('backend_type')->setDisabled(1);
|
92 |
+
if ($model->getIsGlobal()) {
|
93 |
+
#$form->getElement('is_global')->setDisabled(1);
|
94 |
+
}
|
95 |
+
} else {
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->setForm($form);
|
99 |
+
|
100 |
+
return parent::_prepareForm();
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Edit/Tabs.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
3 |
+
{
|
4 |
+
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('attributemanager_tabs');
|
9 |
+
$this->setDestElementId('edit_form');
|
10 |
+
$this->setTitle(Mage::helper('catalog')->__('Attribute Information'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml()
|
14 |
+
{
|
15 |
+
$model = Mage::registry('attributemanager_data');
|
16 |
+
|
17 |
+
$this->addTab('main', array(
|
18 |
+
'label' => Mage::helper('catalog')->__('Properties'),
|
19 |
+
'title' => Mage::helper('catalog')->__('Properties'),
|
20 |
+
'content' => $this->getLayout()->createBlock('attributemanager/edit_tab_main')->toHtml(),
|
21 |
+
'active' => true
|
22 |
+
));
|
23 |
+
|
24 |
+
|
25 |
+
$this->addTab('labels', array(
|
26 |
+
'label' => Mage::helper('catalog')->__('Manage Label / Options'),
|
27 |
+
'title' => Mage::helper('catalog')->__('Manage Label / Options'),
|
28 |
+
'content' => $this->getLayout()->createBlock('attributemanager/edit_tab_options')->toHtml(),
|
29 |
+
));
|
30 |
+
|
31 |
+
/*if ('select' == $model->getFrontendInput()) {
|
32 |
+
$this->addTab('options_section', array(
|
33 |
+
'label' => Mage::helper('catalog')->__('Options Control'),
|
34 |
+
'title' => Mage::helper('catalog')->__('Options Control'),
|
35 |
+
'content' => $this->getLayout()->createBlock('attributemanager/edit_tab_options')->toHtml(),
|
36 |
+
));
|
37 |
+
}*/
|
38 |
+
|
39 |
+
return parent::_beforeToHtml();
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/Custom/Attributemanager/Block/Grid.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Block_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
|
8 |
+
$this->setId('attributemanagergrid');
|
9 |
+
$this->setDefaultSort('attribute_code');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
$this->setTemplate('attributemanager/grid.phtml');
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _prepareCollection()
|
16 |
+
{
|
17 |
+
$model = 'catalog/category_attribute_collection';
|
18 |
+
$sUrl=$this->getUrl('*/*/*', array('_current'=>true));
|
19 |
+
|
20 |
+
$type='customer';
|
21 |
+
$model = 'customer/attribute_collection';
|
22 |
+
|
23 |
+
$this->type=$type;
|
24 |
+
$collection = Mage::getResourceModel($model)
|
25 |
+
->setEntityTypeFilter( Mage::getModel('eav/entity')->setType($type)->getTypeId() )
|
26 |
+
->addFieldToFilter('is_system','0')
|
27 |
+
->addVisibleFilter();
|
28 |
+
|
29 |
+
$this->setCollection($collection);
|
30 |
+
return parent::_prepareCollection();
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _prepareColumns()
|
34 |
+
{
|
35 |
+
$this->addColumn('attribute_code', array(
|
36 |
+
'header'=>Mage::helper('catalog')->__('Attribute Code'),
|
37 |
+
'sortable'=>true,
|
38 |
+
'index'=>'attribute_code'
|
39 |
+
));
|
40 |
+
|
41 |
+
$this->addColumn('frontend_label', array(
|
42 |
+
'header'=>Mage::helper('catalog')->__('Attribute Label'),
|
43 |
+
'sortable'=>true,
|
44 |
+
'index'=>'frontend_label'
|
45 |
+
));
|
46 |
+
/*
|
47 |
+
$this->addColumn('is_visible', array(
|
48 |
+
'header'=>Mage::helper('catalog')->__('Visible'),
|
49 |
+
'sortable'=>true,
|
50 |
+
'index'=>'is_visible_on_front',
|
51 |
+
'type' => 'options',
|
52 |
+
'options' => array(
|
53 |
+
'1' => Mage::helper('catalog')->__('Yes'),
|
54 |
+
'0' => Mage::helper('catalog')->__('No'),
|
55 |
+
),
|
56 |
+
'align' => 'center',
|
57 |
+
));
|
58 |
+
|
59 |
+
$this->addColumn('is_global', array(
|
60 |
+
'header'=>Mage::helper('catalog')->__('Scope'),
|
61 |
+
'sortable'=>true,
|
62 |
+
'index'=>'is_global',
|
63 |
+
'type' => 'options',
|
64 |
+
'options' => array(
|
65 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('catalog')->__('Store View'),
|
66 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('catalog')->__('Website'),
|
67 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'),
|
68 |
+
),
|
69 |
+
'align' => 'center',
|
70 |
+
));
|
71 |
+
*/
|
72 |
+
$this->addColumn('is_required', array(
|
73 |
+
'header'=>Mage::helper('catalog')->__('Required'),
|
74 |
+
'sortable'=>true,
|
75 |
+
'index'=>'is_required',
|
76 |
+
'type' => 'options',
|
77 |
+
'options' => array(
|
78 |
+
'1' => Mage::helper('catalog')->__('Yes'),
|
79 |
+
'0' => Mage::helper('catalog')->__('No'),
|
80 |
+
),
|
81 |
+
'align' => 'center',
|
82 |
+
));
|
83 |
+
/*
|
84 |
+
$this->addColumn('show_in_frontend', array(
|
85 |
+
'header'=>Mage::helper('catalog')->__('Show in Frontend'),
|
86 |
+
'sortable'=>true,
|
87 |
+
'index'=>'show_in_frontend',
|
88 |
+
'type' => 'options',
|
89 |
+
'align' => 'center',
|
90 |
+
'options' => array(
|
91 |
+
'0' => Mage::helper('catalog')->__('Yes'),
|
92 |
+
'1' => Mage::helper('catalog')->__('No'),
|
93 |
+
),
|
94 |
+
));
|
95 |
+
|
96 |
+
|
97 |
+
$this->addColumn('is_user_defined', array(
|
98 |
+
'header'=>Mage::helper('catalog')->__('System'),
|
99 |
+
'sortable'=>true,
|
100 |
+
'index'=>'is_user_defined',
|
101 |
+
'type' => 'options',
|
102 |
+
'align' => 'center',
|
103 |
+
'options' => array(
|
104 |
+
'0' => Mage::helper('catalog')->__('Yes'),
|
105 |
+
'1' => Mage::helper('catalog')->__('No'),
|
106 |
+
),
|
107 |
+
));
|
108 |
+
|
109 |
+
$this->addColumn('is_searchable', array(
|
110 |
+
'header'=>Mage::helper('catalog')->__('Searchable'),
|
111 |
+
'sortable'=>true,
|
112 |
+
'index'=>'is_searchable',
|
113 |
+
'type' => 'options',
|
114 |
+
'options' => array(
|
115 |
+
'1' => Mage::helper('catalog')->__('Yes'),
|
116 |
+
'0' => Mage::helper('catalog')->__('No'),
|
117 |
+
),
|
118 |
+
'align' => 'center',
|
119 |
+
));
|
120 |
+
|
121 |
+
$this->addColumn('is_filterable', array(
|
122 |
+
'header'=>Mage::helper('catalog')->__('Use In Layered Navigation'),
|
123 |
+
'sortable'=>true,
|
124 |
+
'index'=>'is_filterable',
|
125 |
+
'type' => 'options',
|
126 |
+
'options' => array(
|
127 |
+
'1' => Mage::helper('catalog')->__('Filterable (with results)'),
|
128 |
+
'2' => Mage::helper('catalog')->__('Filterable (no results)'),
|
129 |
+
'0' => Mage::helper('catalog')->__('No'),
|
130 |
+
),
|
131 |
+
'align' => 'center',
|
132 |
+
));
|
133 |
+
|
134 |
+
$this->addColumn('is_comparable', array(
|
135 |
+
'header'=>Mage::helper('catalog')->__('Comparable'),
|
136 |
+
'sortable'=>true,
|
137 |
+
'index'=>'is_comparable',
|
138 |
+
'type' => 'options',
|
139 |
+
'options' => array(
|
140 |
+
'1' => Mage::helper('catalog')->__('Yes'),
|
141 |
+
'0' => Mage::helper('catalog')->__('No'),
|
142 |
+
),
|
143 |
+
'align' => 'center',
|
144 |
+
));
|
145 |
+
*/
|
146 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('attributemanager')->__('CSV'));
|
147 |
+
$this->addExportType('*/*/exportXml', Mage::helper('attributemanager')->__('XML'));
|
148 |
+
|
149 |
+
return parent::_prepareColumns();
|
150 |
+
}
|
151 |
+
|
152 |
+
public function addNewButton(){
|
153 |
+
return $this->getButtonHtml(
|
154 |
+
Mage::helper('attributemanager')->__('New Attribute'),
|
155 |
+
"setLocation('".$this->getUrl('*/*/new', array('type' => $this->type,'attribute_id'=>0))."')",
|
156 |
+
"scalable add"
|
157 |
+
);
|
158 |
+
}
|
159 |
+
public function getRowUrl($row)
|
160 |
+
{
|
161 |
+
return $this->getUrl('*/*/edit', array('type' => $this->type,'attribute_id' => $row->getAttributeId()));
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
app/code/community/Custom/Attributemanager/Helper/Data.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
app/code/community/Custom/Attributemanager/Model/Attributemanager.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_attributemanager_Model_attributemanager extends Mage_Eav_Model_Entity_Attribute
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
}
|
8 |
+
|
9 |
+
protected function _beforeSave()
|
10 |
+
{
|
11 |
+
if ( $this->getFrontendInput()=="image"){
|
12 |
+
$this->setBackendModel('catalog/category_attribute_backend_image');
|
13 |
+
$this->setBackendType('varchar');
|
14 |
+
}
|
15 |
+
|
16 |
+
if ( $this->getFrontendInput()=="date"){
|
17 |
+
$this->setBackendModel('eav/entity_attribute_backend_datetime');
|
18 |
+
$this->setBackendType('datetime');
|
19 |
+
}
|
20 |
+
|
21 |
+
if ( $this->getFrontendInput()=="textarea" ){
|
22 |
+
|
23 |
+
$this->setBackendType('text');
|
24 |
+
}
|
25 |
+
|
26 |
+
if ( $this->getFrontendInput()=="text" ){
|
27 |
+
|
28 |
+
$this->setBackendType('varchar');
|
29 |
+
}
|
30 |
+
|
31 |
+
if ( ($this->getFrontendInput()=="multiselect" || $this->getFrontendInput()=="select") ){
|
32 |
+
$this->setData('source_model', 'eav/entity_attribute_source_table');
|
33 |
+
$this->setBackendType('varchar');
|
34 |
+
}
|
35 |
+
|
36 |
+
if ($this->getFrontendInput()=="boolean"){
|
37 |
+
$this->setData('source_model', 'eav/entity_attribute_source_boolean');
|
38 |
+
$this->setBackendType('int');
|
39 |
+
$this->setFrontendInput("select");
|
40 |
+
}
|
41 |
+
|
42 |
+
return parent::_beforeSave();
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Custom/Attributemanager/controllers/IndexController.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Custom_Attributemanager_IndexController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
|
5 |
+
protected $_customerTypeId;
|
6 |
+
protected $_categoryTypeId;
|
7 |
+
protected $_customer_addressTypeId;
|
8 |
+
protected $_type;
|
9 |
+
|
10 |
+
public function preDispatch()
|
11 |
+
{
|
12 |
+
parent::preDispatch();
|
13 |
+
$this->_customerTypeId = Mage::getModel('eav/entity')->setType('customer')->getTypeId();
|
14 |
+
$this->_categoryTypeId = Mage::getModel('eav/entity')->setType('catalog_category')->getTypeId();
|
15 |
+
$this->_customer_addressTypeId = Mage::getModel('eav/entity')->setType('customer_address')->getTypeId();
|
16 |
+
if ($this->getRequest ()->getParam ( 'type' )){
|
17 |
+
switch ($this->getRequest ()->getParam ( 'type' )) {
|
18 |
+
case "customer" :
|
19 |
+
$this->_type = 'customer';
|
20 |
+
break;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _initAction($ids=null) {
|
26 |
+
$this->loadLayout($ids);
|
27 |
+
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function categoryAction()
|
32 |
+
{
|
33 |
+
$this->_initAction()
|
34 |
+
->_setActiveMenu('customer/custom')
|
35 |
+
->_addContent($this->getLayout()->createBlock('attributemanager/Grid'));
|
36 |
+
$this->renderLayout();
|
37 |
+
}
|
38 |
+
|
39 |
+
public function customerAction()
|
40 |
+
{
|
41 |
+
$this->_initAction()
|
42 |
+
->_setActiveMenu('customer/custom')
|
43 |
+
->_addContent($this->getLayout()->createBlock('attributemanager/Grid'));
|
44 |
+
$this->renderLayout();
|
45 |
+
}
|
46 |
+
|
47 |
+
public function addressAction()
|
48 |
+
{
|
49 |
+
$this->_initAction()
|
50 |
+
->_setActiveMenu('customer/custom')
|
51 |
+
->_addContent($this->getLayout()->createBlock('attributemanager/Grid'));
|
52 |
+
$this->renderLayout();
|
53 |
+
}
|
54 |
+
|
55 |
+
public function editAction() {
|
56 |
+
$id = $this->getRequest()->getParam('attribute_id');
|
57 |
+
$model = Mage::getModel('eav/entity_attribute');
|
58 |
+
$model->load($id);
|
59 |
+
|
60 |
+
/* if(0!==$id){
|
61 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
62 |
+
$model->setData("sort_order",$db->fetchOne("select sort_order from eav_entity_attribute where attribute_id=$id"));
|
63 |
+
}
|
64 |
+
*/
|
65 |
+
|
66 |
+
if ($model->getId() || $id == 0) {
|
67 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
68 |
+
if (!empty($data)) {
|
69 |
+
$model->setData($data);
|
70 |
+
}
|
71 |
+
|
72 |
+
Mage::register('attributemanager_data', $model);
|
73 |
+
|
74 |
+
$this->loadLayout();
|
75 |
+
$this->_setActiveMenu('customer/custom');
|
76 |
+
|
77 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
78 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
79 |
+
|
80 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
81 |
+
|
82 |
+
$this
|
83 |
+
->_addContent($this->getLayout()->createBlock('attributemanager/edit'))
|
84 |
+
->_addLeft($this->getLayout()->createBlock('attributemanager/edit_tabs'))
|
85 |
+
;
|
86 |
+
|
87 |
+
$this->renderLayout();
|
88 |
+
} else {
|
89 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('attributemanager')->__('Item does not exist'));
|
90 |
+
$this->_redirect('*/*/');
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
public function newAction() {
|
95 |
+
$this->_forward('edit');
|
96 |
+
}
|
97 |
+
|
98 |
+
public function validateAction()
|
99 |
+
{
|
100 |
+
$response = new Varien_Object();
|
101 |
+
$response->setError(false);
|
102 |
+
|
103 |
+
$attributeCode = $this->getRequest()->getParam('type');
|
104 |
+
$attributeId = $this->getRequest()->getParam('attribute_id');
|
105 |
+
switch ($attributeCode){
|
106 |
+
case "catalog_category":
|
107 |
+
$this->_entityTypeId=$this->_categoryTypeId;
|
108 |
+
break;
|
109 |
+
|
110 |
+
case "customer":
|
111 |
+
$this->_entityTypeId=$this->_customerTypeId;
|
112 |
+
break;
|
113 |
+
|
114 |
+
case "customer_address":
|
115 |
+
$this->_entityTypeId=$this->_customer_addressTypeId;
|
116 |
+
break;
|
117 |
+
}
|
118 |
+
$attribute = Mage::getModel('eav/entity_attribute')
|
119 |
+
->loadByCode($this->_entityTypeId, $attributeCode);
|
120 |
+
|
121 |
+
if ($attribute->getId() && !$attributeId) {
|
122 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('Attribute with the same code already exists'));
|
123 |
+
$this->_initLayoutMessages('adminhtml/session');
|
124 |
+
$response->setError(true);
|
125 |
+
$response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
|
126 |
+
}
|
127 |
+
|
128 |
+
$this->getResponse()->setBody($response->toJson());
|
129 |
+
}
|
130 |
+
|
131 |
+
public function saveAction() {
|
132 |
+
if ($data = $this->getRequest()->getPost()) {
|
133 |
+
|
134 |
+
$model = Mage::getModel('attributemanager/attributemanager');
|
135 |
+
$model->setData($data);
|
136 |
+
|
137 |
+
if( $this->getRequest()->getParam('attribute_id') > 0 ) {
|
138 |
+
$model->setId($this->getRequest()->getParam('attribute_id'));
|
139 |
+
}
|
140 |
+
|
141 |
+
try {
|
142 |
+
|
143 |
+
if ($model->getCreatedTime() == NULL || $model->getUpdateTime() == NULL) {
|
144 |
+
$model->setCreatedTime(now())
|
145 |
+
->setUpdateTime(now());
|
146 |
+
} else {
|
147 |
+
$model->setUpdateTime(now());
|
148 |
+
}
|
149 |
+
|
150 |
+
$model->save();
|
151 |
+
|
152 |
+
$id=$model->getId();
|
153 |
+
|
154 |
+
if($data['entity_type_id'] == '1' && $data['attribute_code']) {
|
155 |
+
|
156 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
157 |
+
$eavConfig = Mage::getSingleton('eav/config');
|
158 |
+
$attribute = $eavConfig->getAttribute('customer', $data['attribute_code']);
|
159 |
+
|
160 |
+
//if($data['show_in_frontend'] == '1') {
|
161 |
+
$attribute->setData('used_in_forms', array('customer_account_edit',
|
162 |
+
'customer_account_create',
|
163 |
+
'adminhtml_customer'));
|
164 |
+
/* } else {
|
165 |
+
$attribute->setData('used_in_forms', array('adminhtml_customer'));
|
166 |
+
} */
|
167 |
+
|
168 |
+
if($data['frontend_input'] == 'boolean') {
|
169 |
+
$attribute->setData('source_model', 'eav/entity_attribute_source_boolean');
|
170 |
+
}
|
171 |
+
|
172 |
+
$attribute->save();
|
173 |
+
}
|
174 |
+
|
175 |
+
|
176 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('attributemanager')->__('Item was successfully saved'));
|
177 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
178 |
+
|
179 |
+
if ($this->getRequest()->getParam('back')) {
|
180 |
+
$this->_redirect('*/*/edit', array('type'=>$this->getRequest()->getParam('type'), 'attribute_id' => $id));
|
181 |
+
return;
|
182 |
+
}
|
183 |
+
|
184 |
+
$this->_redirect('*/*/'.$this->_type.'/filter//');
|
185 |
+
return;
|
186 |
+
} catch (Exception $e) {
|
187 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
188 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
189 |
+
$this->_redirect('*/*/edit', array('type'=>$this->getRequest()->getParam('type'),'attribute_id' => $this->getRequest()->getParam('attribute_id')));
|
190 |
+
return;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('attributemanager')->__('Unable to find item to save'));
|
194 |
+
$this->_redirect('*/*/'.$this->_type.'/filter//');
|
195 |
+
}
|
196 |
+
|
197 |
+
public function deleteAction() {
|
198 |
+
if( $this->getRequest()->getParam('attribute_id') > 0 ) {
|
199 |
+
try {
|
200 |
+
$model = Mage::getModel('eav/entity_attribute');
|
201 |
+
|
202 |
+
$model->setId($this->getRequest()->getParam('attribute_id'))
|
203 |
+
->delete();
|
204 |
+
|
205 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
206 |
+
$this->_redirect('*/*/'.$this->_type.'/filter//');
|
207 |
+
} catch (Exception $e) {
|
208 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
209 |
+
$this->_redirect('*/*/edit', array('type'=>$this->getRequest()->getParam('type'),'attribute_id' => $this->getRequest()->getParam('attribute_id')));
|
210 |
+
}
|
211 |
+
}
|
212 |
+
$this->_redirect('*/*/'.$this->_type.'/filter//');
|
213 |
+
}
|
214 |
+
|
215 |
+
public function massDeleteAction() {
|
216 |
+
$categoriesattributesIds = $this->getRequest()->getParam('attributemanager');
|
217 |
+
if(!is_array($categoriesattributesIds)) {
|
218 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
219 |
+
} else {
|
220 |
+
try {
|
221 |
+
foreach ($categoriesattributesIds as $categoriesattributesId) {
|
222 |
+
$categoriesattributes = Mage::getModel('eav/entity_attribute')->load($categoriesattributesId);
|
223 |
+
$categoriesattributes->delete();
|
224 |
+
}
|
225 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
226 |
+
Mage::helper('adminhtml')->__(
|
227 |
+
'Total of %d record(s) were successfully deleted', count($categoriesattributesIds)
|
228 |
+
)
|
229 |
+
);
|
230 |
+
} catch (Exception $e) {
|
231 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
232 |
+
}
|
233 |
+
}
|
234 |
+
$this->_redirect('*/*/'.$this->_type.'/filter//');
|
235 |
+
}
|
236 |
+
|
237 |
+
public function exportCsvAction()
|
238 |
+
{
|
239 |
+
$fileName = $this->_type.'attributes.csv';
|
240 |
+
$content = $this->getLayout()->createBlock('attributemanager/grid')
|
241 |
+
->getCsv();
|
242 |
+
|
243 |
+
$this->_sendUploadResponse($fileName, $content);
|
244 |
+
}
|
245 |
+
|
246 |
+
public function exportXmlAction()
|
247 |
+
{
|
248 |
+
$fileName = $this->_type.'attributes.xml';
|
249 |
+
$content = $this->getLayout()->createBlock('attributemanager/grid')
|
250 |
+
->getXml();
|
251 |
+
|
252 |
+
$this->_sendUploadResponse($fileName, $content);
|
253 |
+
}
|
254 |
+
|
255 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
256 |
+
{
|
257 |
+
$response = $this->getResponse();
|
258 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
259 |
+
$response->setHeader('Pragma', 'public', true);
|
260 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
261 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
262 |
+
$response->setHeader('Last-Modified', date('r'));
|
263 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
264 |
+
$response->setHeader('Content-Length', strlen($content));
|
265 |
+
$response->setHeader('Content-type', $contentType);
|
266 |
+
$response->setBody($content);
|
267 |
+
$response->sendResponse();
|
268 |
+
exit;
|
269 |
+
}
|
270 |
+
}
|
app/code/community/Custom/Attributemanager/etc/config.xml
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Custom_Attributemanager>
|
5 |
+
<version>0.0.6</version>
|
6 |
+
</Custom_Attributemanager>
|
7 |
+
</modules>
|
8 |
+
<admin>
|
9 |
+
<routers>
|
10 |
+
<attributemanager>
|
11 |
+
<use>admin</use>
|
12 |
+
<args>
|
13 |
+
<module>Custom_Attributemanager</module>
|
14 |
+
<frontName>attributemanager</frontName>
|
15 |
+
</args>
|
16 |
+
</attributemanager>
|
17 |
+
</routers>
|
18 |
+
</admin>
|
19 |
+
|
20 |
+
<adminhtml>
|
21 |
+
<menu>
|
22 |
+
<customer>
|
23 |
+
<children>
|
24 |
+
<attrmanager>
|
25 |
+
<title>Attribute Manager</title>
|
26 |
+
<sort_order>600</sort_order>
|
27 |
+
<children>
|
28 |
+
<customer translate="title" module="attributemanager">
|
29 |
+
<title>Customer's Attributes</title>
|
30 |
+
<action>attributemanager/index/customer/filter//</action>
|
31 |
+
</customer>
|
32 |
+
</children>
|
33 |
+
</attrmanager>
|
34 |
+
</children>
|
35 |
+
</customer>
|
36 |
+
</menu>
|
37 |
+
<acl>
|
38 |
+
<resources>
|
39 |
+
<all>
|
40 |
+
<title>Allow Everything</title>
|
41 |
+
</all>
|
42 |
+
<admin>
|
43 |
+
<children>
|
44 |
+
<Custom_Attributemanager>
|
45 |
+
<title>Attributemanager Module</title>
|
46 |
+
<sort_order>10</sort_order>
|
47 |
+
</Custom_Attributemanager>
|
48 |
+
</children>
|
49 |
+
</admin>
|
50 |
+
</resources>
|
51 |
+
</acl>
|
52 |
+
<layout>
|
53 |
+
<updates>
|
54 |
+
<attributemanager>
|
55 |
+
<file>attributemanager.xml</file>
|
56 |
+
</attributemanager>
|
57 |
+
</updates>
|
58 |
+
</layout>
|
59 |
+
</adminhtml>
|
60 |
+
|
61 |
+
<frontend>
|
62 |
+
<layout>
|
63 |
+
<updates>
|
64 |
+
<attributemanager>
|
65 |
+
<file>attributemanager.xml</file>
|
66 |
+
</attributemanager>
|
67 |
+
</updates>
|
68 |
+
</layout>
|
69 |
+
</frontend>
|
70 |
+
|
71 |
+
<global>
|
72 |
+
<models>
|
73 |
+
<attributemanager>
|
74 |
+
<class>Custom_Attributemanager_Model</class>
|
75 |
+
</attributemanager>
|
76 |
+
</models>
|
77 |
+
<blocks>
|
78 |
+
<attributemanager>
|
79 |
+
<class>Custom_Attributemanager_Block</class>
|
80 |
+
</attributemanager>
|
81 |
+
<adminhtml>
|
82 |
+
<rewrite>
|
83 |
+
<customer_edit_tab_account>Custom_Attributemanager_Block_Adminhtml_Customer_Edit_Tab_Account</customer_edit_tab_account>
|
84 |
+
</rewrite>
|
85 |
+
</adminhtml>
|
86 |
+
</blocks>
|
87 |
+
<helpers>
|
88 |
+
<attributemanager>
|
89 |
+
<class>Custom_Attributemanager_Helper</class>
|
90 |
+
</attributemanager>
|
91 |
+
</helpers>
|
92 |
+
</global>
|
93 |
+
</config>
|
app/design/adminhtml/default/default/layout/attributemanager.xml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<layout version="0.9.1.1">
|
3 |
+
<!-- informations concernant la page d'accueil du module -->
|
4 |
+
<attributemanager_index>
|
5 |
+
<!-- informations concernant le block content -->
|
6 |
+
<reference name="content">
|
7 |
+
<block type="attributemanager/index" name="attributemanager" as="attributemanager" template="attributemanager/index.phtml" />
|
8 |
+
</reference>
|
9 |
+
</attributemanager_index>
|
10 |
+
|
11 |
+
|
12 |
+
<attributemanager_category>
|
13 |
+
<reference name="content">
|
14 |
+
<block type="attributemanager/attributemanagergrid" name="attributemanagergrid" as="attributemanagergrid" template="attributemanager/grid.phtml" />
|
15 |
+
</reference>
|
16 |
+
</attributemanager_category>
|
17 |
+
<attributemanager_customer>
|
18 |
+
<reference name="content">
|
19 |
+
<block type="attributemanager/attributemanagergrid" name="attributemanagergrid" as="attributemanagergrid" template="attributemanager/grid.phtml" />
|
20 |
+
</reference>
|
21 |
+
</attributemanager_customer>
|
22 |
+
<attributemanager_address>
|
23 |
+
<reference name="content">
|
24 |
+
<block type="attributemanager/attributemanagergrid" name="attributemanagergrid" as="attributemanagergrid" template="attributemanager/grid.phtml" />
|
25 |
+
</reference>
|
26 |
+
</attributemanager_address>
|
27 |
+
|
28 |
+
<attributemanager_edit>
|
29 |
+
<reference name="content">
|
30 |
+
<block type="attributemanager/attributemanageredit" name="attributemanageredit" as="attributemanageredit" template="attributemanager/options.phtml" />
|
31 |
+
</reference>
|
32 |
+
</attributemanager_edit>
|
33 |
+
</layout>
|
app/design/adminhtml/default/default/template/attributemanager/grid.phtml
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="content-header">
|
2 |
+
<table cellspacing="0">
|
3 |
+
<tr>
|
4 |
+
<td style="width:50%;"><h3 class="icon-head head-products"><?php echo Mage::helper('attributemanager')->__('Manage attributes') ?></h3></td>
|
5 |
+
|
6 |
+
<td class="form-buttons"><?php echo $this->addNewButton()
|
7 |
+
?></td>
|
8 |
+
</tr>
|
9 |
+
</table>
|
10 |
+
</div>
|
11 |
+
<div>
|
12 |
+
|
13 |
+
<?php
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Template for Mage_Adminhtml_Block_Widget_Grid
|
17 |
+
*
|
18 |
+
* getId()
|
19 |
+
* getCollection()
|
20 |
+
* getColumns()
|
21 |
+
* getPagerVisibility()
|
22 |
+
* getVarNamePage()
|
23 |
+
*/
|
24 |
+
$numColumns = sizeof($this->getColumns());
|
25 |
+
?>
|
26 |
+
<?php if($this->getCollection()): ?>
|
27 |
+
<?php if($this->canDisplayContainer()): ?>
|
28 |
+
<?php if($this->getGridHeader()): ?>
|
29 |
+
<div class="content-header">
|
30 |
+
<table cellspacing="0">
|
31 |
+
<tr>
|
32 |
+
<td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
|
33 |
+
</tr>
|
34 |
+
</table>
|
35 |
+
</div>
|
36 |
+
<?php endif ?>
|
37 |
+
|
38 |
+
<div id="<?php echo $this->getId() ?>">
|
39 |
+
<?php else: ?>
|
40 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
41 |
+
<?php endif; ?>
|
42 |
+
<?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
|
43 |
+
<table cellspacing="0" class="actions">
|
44 |
+
<tr>
|
45 |
+
<?php if($this->getPagerVisibility()): ?>
|
46 |
+
<td class="pager">
|
47 |
+
<?php echo $this->__('Page') ?>
|
48 |
+
|
49 |
+
<?php $_curPage = $this->getCollection()->getCurPage() ?>
|
50 |
+
<?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
|
51 |
+
<?php if($_curPage>1): ?>
|
52 |
+
<a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getId() ?>JsObject.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
|
53 |
+
<?php else: ?>
|
54 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
|
55 |
+
<?php endif; ?>
|
56 |
+
|
57 |
+
<input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getId() ?>JsObject.inputPage(event, '<?php echo $_lastPage ?>')"/>
|
58 |
+
|
59 |
+
<?php if($_curPage < $_lastPage): ?>
|
60 |
+
<a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getId() ?>JsObject.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
|
61 |
+
<?php else: ?>
|
62 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
|
63 |
+
<?php endif; ?>
|
64 |
+
|
65 |
+
<?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
|
66 |
+
<span class="separator">|</span>
|
67 |
+
<?php echo $this->__('View') ?>
|
68 |
+
<select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getId() ?>JsObject.loadByElement(this)">
|
69 |
+
<option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
|
70 |
+
<option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
|
71 |
+
<option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
|
72 |
+
<option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
|
73 |
+
<option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
|
74 |
+
</select>
|
75 |
+
<?php echo $this->__('per page') ?><span class="separator">|</span>
|
76 |
+
<?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
|
77 |
+
<span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
|
78 |
+
<?php if($this->getRssLists()): ?>
|
79 |
+
<?php foreach ($this->getRssLists() as $_rss): ?>
|
80 |
+
<span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
|
81 |
+
<?php endforeach ?>
|
82 |
+
<?php endif; ?>
|
83 |
+
</td>
|
84 |
+
<?php endif ?>
|
85 |
+
<?php if($this->getExportTypes()): ?>
|
86 |
+
<td class="export a-right">
|
87 |
+
<img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/> <?php echo $this->__('Export to:') ?>
|
88 |
+
<select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
|
89 |
+
<?php foreach ($this->getExportTypes() as $_type): ?>
|
90 |
+
<option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
|
91 |
+
<?php endforeach; ?>
|
92 |
+
</select>
|
93 |
+
<?php echo $this->getExportButtonHtml() ?>
|
94 |
+
</td>
|
95 |
+
<?php endif; ?>
|
96 |
+
<td class="filter-actions a-right">
|
97 |
+
<?php echo $this->getMainButtonsHtml() ?>
|
98 |
+
</td>
|
99 |
+
</tr>
|
100 |
+
</table>
|
101 |
+
<?php endif; ?>
|
102 |
+
<?php if($this->getMassactionBlock()->isAvailable()): ?>
|
103 |
+
<?php echo $this->getMassactionBlockHtml() ?>
|
104 |
+
<?php endif ?>
|
105 |
+
<div class="grid">
|
106 |
+
<div class="hor-scroll">
|
107 |
+
<table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
|
108 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
109 |
+
<col <?php echo $_column->getHtmlProperty() ?> />
|
110 |
+
<?php endforeach; ?>
|
111 |
+
<?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
|
112 |
+
<thead>
|
113 |
+
<?php if ($this->getHeadersVisibility()): ?>
|
114 |
+
<tr class="headings">
|
115 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
116 |
+
<th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
|
117 |
+
<?php endforeach; ?>
|
118 |
+
</tr>
|
119 |
+
<?php endif; ?>
|
120 |
+
<?php if ($this->getFilterVisibility()): ?>
|
121 |
+
<tr class="filter">
|
122 |
+
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
|
123 |
+
<th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
|
124 |
+
<?php endforeach; ?>
|
125 |
+
</tr>
|
126 |
+
<?php endif ?>
|
127 |
+
</thead>
|
128 |
+
<?php endif; ?>
|
129 |
+
<?php if ($this->getCountTotals()): ?>
|
130 |
+
<tfoot>
|
131 |
+
<tr>
|
132 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
133 |
+
<th class="<?php echo $_column->getCssProperty() ?>"><?php echo $_column->getRowField($_column->getGrid()->getTotals()) ?> </th>
|
134 |
+
<?php endforeach; ?>
|
135 |
+
</tr>
|
136 |
+
</tfoot>
|
137 |
+
<?php endif; ?>
|
138 |
+
<tbody>
|
139 |
+
<?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
|
140 |
+
<?php foreach ($this->getCollection() as $_index=>$_item): ?>
|
141 |
+
<tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
|
142 |
+
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
|
143 |
+
<td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>"><?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : ' ') ?></td>
|
144 |
+
<?php endforeach; ?>
|
145 |
+
</tr>
|
146 |
+
<?php endforeach; ?>
|
147 |
+
<?php elseif ($this->getEmptyText()): ?>
|
148 |
+
<tr>
|
149 |
+
<td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="100"><?php echo $this->getEmptyText() ?></td>
|
150 |
+
</tr>
|
151 |
+
<?php endif; ?>
|
152 |
+
</tbody>
|
153 |
+
</table>
|
154 |
+
</div>
|
155 |
+
</div>
|
156 |
+
<?php if($this->canDisplayContainer()): ?>
|
157 |
+
</div>
|
158 |
+
<script type="text/javascript">
|
159 |
+
//<![CDATA[
|
160 |
+
<?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
|
161 |
+
<?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
|
162 |
+
<?php if($this->getRowClickCallback()): ?>
|
163 |
+
<?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
|
164 |
+
<?php endif; ?>
|
165 |
+
<?php if($this->getCheckboxCheckCallback()): ?>
|
166 |
+
<?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
|
167 |
+
<?php endif; ?>
|
168 |
+
<?php if($this->getRowInitCallback()): ?>
|
169 |
+
<?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
|
170 |
+
<?php echo $this->getJsObjectName() ?>.rows.each(function(row){<?php echo $this->getRowInitCallback() ?>(<?php echo $this->getJsObjectName() ?>, row)});
|
171 |
+
<?php endif; ?>
|
172 |
+
<?php if($this->getMassactionBlock()->isAvailable()): ?>
|
173 |
+
<?php echo $this->getMassactionBlock()->getJavaScript() ?>
|
174 |
+
<?php endif ?>
|
175 |
+
//]]>
|
176 |
+
</script>
|
177 |
+
<?php endif; ?>
|
178 |
+
<?php endif ?>
|
179 |
+
</div>
|
app/design/adminhtml/default/default/template/attributemanager/index.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="content-header">
|
2 |
+
<table cellspacing="0">
|
3 |
+
<tr>
|
4 |
+
<td style="width:50%;"><h3 class="icon-head head-products"><?php echo Mage::helper('attributemanager')->__('Manage attributes') ?></h3></td>
|
5 |
+
<td class="a-right">
|
6 |
+
</td>
|
7 |
+
</tr>
|
8 |
+
</table>
|
9 |
+
</div>
|
10 |
+
<div>
|
11 |
+
<div align="center">
|
12 |
+
<h3 class="icon-head"><u><?php echo Mage::helper('attributemanager')->__('Choose attributes to manage') ?></u></h3>
|
13 |
+
<br/><br/>
|
14 |
+
<h3 class="icon-head">
|
15 |
+
<a href="<?php echo $this->getUrl('*');?>index/category/filter//"><?php echo Mage::helper('attributemanager')->__('Categories attributes') ?></a>
|
16 |
+
<br/>
|
17 |
+
<a href="<?php echo $this->getUrl('*');?>index/customer/filter//"><?php echo Mage::helper('attributemanager')->__('Customers attributes') ?></a>
|
18 |
+
<br/>
|
19 |
+
<a href="<?php echo $this->getUrl('*');?>index/address/filter//"><?php echo Mage::helper('attributemanager')->__('Customer\'s address attributes') ?></a></h3>
|
20 |
+
</div>
|
21 |
+
</div>
|
app/design/adminhtml/default/default/template/attributemanager/js.phtml
ADDED
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |