Version Notes
In some case you want to add some additional text for downloadable link file into product page such as user manual for your product.
Download this release
Release Info
Developer | Magento Core Team |
Extension | CustomField |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute.php +12 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit.php +45 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit/Form.php +19 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit/Tab/Customfield.php +60 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit/Tab/Form.php +54 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit/Tabs.php +24 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Grid.php +122 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Block.php +12 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Edit.php +48 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Edit/Form.php +19 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Edit/Tab/Form.php +29 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Edit/Tabs.php +24 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Grid.php +114 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Catalog/Product/Edit/Tabs.php +187 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield.php +12 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Edit.php +45 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Edit/Form.php +19 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Edit/Tab/Form.php +58 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Edit/Tabs.php +24 -0
- app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Grid.php +116 -0
- app/code/community/Magestore/Customfield/Block/Customfield.php +60 -0
- app/code/community/Magestore/Customfield/Helper/Data.php +86 -0
- app/code/community/Magestore/Customfield/Model/Attribute.php +108 -0
- app/code/community/Magestore/Customfield/Model/Attributevalue.php +12 -0
- app/code/community/Magestore/Customfield/Model/Block.php +12 -0
- app/code/community/Magestore/Customfield/Model/Customfield.php +10 -0
- app/code/community/Magestore/Customfield/Model/Mysql4/Attribute.php +10 -0
- app/code/community/Magestore/Customfield/Model/Mysql4/Attribute/Collection.php +10 -0
- app/code/community/Magestore/Customfield/Model/Mysql4/Attributevalue.php +48 -0
- app/code/community/Magestore/Customfield/Model/Mysql4/Block.php +10 -0
- app/code/community/Magestore/Customfield/Model/Mysql4/Block/Collection.php +10 -0
- app/code/community/Magestore/Customfield/Model/Mysql4/Customfield.php +10 -0
- app/code/community/Magestore/Customfield/Model/Mysql4/Customfield/Collection.php +10 -0
- app/code/community/Magestore/Customfield/Model/Status.php +15 -0
- app/code/community/Magestore/Customfield/controllers/Adminhtml/AttributeController.php +188 -0
- app/code/community/Magestore/Customfield/controllers/Adminhtml/BlockController.php +154 -0
- app/code/community/Magestore/Customfield/controllers/Adminhtml/CustomfieldController.php +214 -0
- app/code/community/Magestore/Customfield/controllers/IndexController.php +47 -0
- app/code/community/Magestore/Customfield/etc/config.xml +152 -0
- app/code/community/Magestore/Customfield/sql/customfield_setup/mysql4-install-0.1.0.php +29 -0
- app/design/adminhtml/default/default/layout/customfield.xml +14 -0
- app/design/frontend/default/default/layout/customfield.xml +17 -0
- app/design/frontend/default/default/template/customfield/customfield.phtml +3 -0
- app/etc/modules/Magestore_Customfield.xml +9 -0
- package.xml +21 -0
app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Customfield_Block_Adminhtml_Attribute extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_attribute';
|
7 |
+
$this->_blockGroup = 'customfield';
|
8 |
+
$this->_headerText = Mage::helper('customfield')->__('Attribute Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('customfield')->__('Add Attribute');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Attribute_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'customfield';
|
11 |
+
$this->_controller = 'adminhtml_attribute';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('customfield')->__('Save Attribute'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('customfield')->__('Delete Attribute'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('attribute_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'attribute_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'attribute_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('attribute_data') && Mage::registry('attribute_data')->getId() ) {
|
40 |
+
return Mage::helper('customfield')->__("Edit Attribute '%s'", $this->htmlEscape(Mage::registry('attribute_data')->getAttributeCode()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('customfield')->__('Add Attribute');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Attribute_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit/Tab/Customfield.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Attribute_Edit_Tab_Customfield extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
public function _prepareLayout()
|
6 |
+
{
|
7 |
+
parent::_prepareLayout();
|
8 |
+
$form = new Varien_Data_Form();
|
9 |
+
$this->setForm($form);
|
10 |
+
$fieldset = $form->addFieldset('customfield_form', array('legend'=>Mage::helper('customfield')->__('Custom Fields')));
|
11 |
+
|
12 |
+
$attributes = Mage::getSingleton("customfield/attribute")->getCollection();
|
13 |
+
|
14 |
+
$product_id = Mage::registry('current_product')->getId();
|
15 |
+
$attributevalues = Mage::getResourceSingleton("customfield/attributevalue")->getAttributeValues($product_id);
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
$data = array();
|
20 |
+
if($attributevalues)
|
21 |
+
{
|
22 |
+
foreach($attributevalues as $attributevalue)
|
23 |
+
{
|
24 |
+
$data["customfield[". $attributevalue['attribute_code'] . "]"]= $attributevalue['value'];
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
foreach($attributes as $attribute)
|
30 |
+
{
|
31 |
+
$type = $attribute->getType();
|
32 |
+
|
33 |
+
$attribute_code = Mage::helper('customfield')->getCustomAttributeCode($attribute->getId());
|
34 |
+
$attribute_code = "customfield[" . $attribute_code . "]";
|
35 |
+
|
36 |
+
$note = "";
|
37 |
+
if($type == 'file')
|
38 |
+
{
|
39 |
+
if(isset($data[$attribute_code]))
|
40 |
+
{
|
41 |
+
$note = $data[$attribute_code];
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
$fieldset->addField($attribute_code, $type, array(
|
46 |
+
'label' => Mage::helper('customfield')->__($attribute->getName()),
|
47 |
+
|
48 |
+
'required' => false,
|
49 |
+
'name' => $attribute_code,
|
50 |
+
'note' => $note,
|
51 |
+
));
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
$form->setValues($data);
|
57 |
+
$this->setForm($form);
|
58 |
+
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Attribute_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('attribute_form', array('legend'=>Mage::helper('customfield')->__('Attribute information')));
|
10 |
+
|
11 |
+
|
12 |
+
$fieldset->addField('name', 'text', array(
|
13 |
+
'label' => Mage::helper('customfield')->__('Title'),
|
14 |
+
'class' => 'required-entry',
|
15 |
+
'required' => true,
|
16 |
+
'name' => 'name',
|
17 |
+
));
|
18 |
+
|
19 |
+
$fieldset->addField('alias', 'text', array(
|
20 |
+
'label' => Mage::helper('customfield')->__('Alias'),
|
21 |
+
'class' => 'required-entry',
|
22 |
+
'required' => true,
|
23 |
+
'name' => 'alias',
|
24 |
+
));
|
25 |
+
|
26 |
+
$fieldset->addField('type', 'select', array(
|
27 |
+
'label' => Mage::helper('customfield')->__('Type'),
|
28 |
+
'name' => 'type',
|
29 |
+
'values' => array(
|
30 |
+
array(
|
31 |
+
'value' => 'file',
|
32 |
+
'label' => Mage::helper('customfield')->__('File'),
|
33 |
+
),
|
34 |
+
|
35 |
+
array(
|
36 |
+
'value' => 'text',
|
37 |
+
'label' => Mage::helper('customfield')->__('Text'),
|
38 |
+
),
|
39 |
+
),
|
40 |
+
));
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
if ( Mage::getSingleton('adminhtml/session')->getAttributeData() )
|
46 |
+
{
|
47 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getAttributeData());
|
48 |
+
Mage::getSingleton('adminhtml/session')->setAttributeData(null);
|
49 |
+
} elseif ( Mage::registry('attribute_data') ) {
|
50 |
+
$form->setValues(Mage::registry('attribute_data')->getData());
|
51 |
+
}
|
52 |
+
return parent::_prepareForm();
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Attribute_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('attribute_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('customfield')->__('Attribute Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('customfield')->__('Attribute Information'),
|
18 |
+
'title' => Mage::helper('customfield')->__('Attribute Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('customfield/adminhtml_attribute_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Attribute/Grid.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Attribute_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('attributeGrid');
|
9 |
+
$this->setDefaultSort('id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('customfield/attribute')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('id', array(
|
24 |
+
'header' => Mage::helper('customfield')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('name', array(
|
31 |
+
'header' => Mage::helper('customfield')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'name',
|
34 |
+
));
|
35 |
+
|
36 |
+
$this->addColumn('alias', array(
|
37 |
+
'header' => Mage::helper('customfield')->__('Alias'),
|
38 |
+
'align' =>'left',
|
39 |
+
'index' => 'alias',
|
40 |
+
));
|
41 |
+
|
42 |
+
$this->addColumn('type', array(
|
43 |
+
'header' => Mage::helper('customfield')->__('Type'),
|
44 |
+
'align' =>'left',
|
45 |
+
'index' => 'type',
|
46 |
+
));
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
$this->addColumn('status', array(
|
51 |
+
'header' => Mage::helper('customfield')->__('Status'),
|
52 |
+
'align' => 'left',
|
53 |
+
'width' => '80px',
|
54 |
+
'index' => 'status',
|
55 |
+
'type' => 'options',
|
56 |
+
'options' => array(
|
57 |
+
1 => 'Enabled',
|
58 |
+
2 => 'Disabled',
|
59 |
+
),
|
60 |
+
));
|
61 |
+
|
62 |
+
$this->addColumn('action',
|
63 |
+
array(
|
64 |
+
'header' => Mage::helper('customfield')->__('Action'),
|
65 |
+
'width' => '100',
|
66 |
+
'type' => 'action',
|
67 |
+
'getter' => 'getId',
|
68 |
+
'actions' => array(
|
69 |
+
array(
|
70 |
+
'caption' => Mage::helper('customfield')->__('Edit'),
|
71 |
+
'url' => array('base'=> '*/*/edit'),
|
72 |
+
'field' => 'id'
|
73 |
+
)
|
74 |
+
),
|
75 |
+
'filter' => false,
|
76 |
+
'sortable' => false,
|
77 |
+
'index' => 'stores',
|
78 |
+
'is_system' => true,
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('customfield')->__('CSV'));
|
82 |
+
$this->addExportType('*/*/exportXml', Mage::helper('customfield')->__('XML'));
|
83 |
+
|
84 |
+
return parent::_prepareColumns();
|
85 |
+
}
|
86 |
+
|
87 |
+
protected function _prepareMassaction()
|
88 |
+
{
|
89 |
+
$this->setMassactionIdField('id');
|
90 |
+
$this->getMassactionBlock()->setFormFieldName('customfield');
|
91 |
+
|
92 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
93 |
+
'label' => Mage::helper('customfield')->__('Delete'),
|
94 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
95 |
+
'confirm' => Mage::helper('customfield')->__('Are you sure?')
|
96 |
+
));
|
97 |
+
|
98 |
+
$statuses = Mage::getSingleton('customfield/status')->getOptionArray();
|
99 |
+
|
100 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
101 |
+
$this->getMassactionBlock()->addItem('status', array(
|
102 |
+
'label'=> Mage::helper('customfield')->__('Change status'),
|
103 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
104 |
+
'additional' => array(
|
105 |
+
'visibility' => array(
|
106 |
+
'name' => 'status',
|
107 |
+
'type' => 'select',
|
108 |
+
'class' => 'required-entry',
|
109 |
+
'label' => Mage::helper('customfield')->__('Status'),
|
110 |
+
'values' => $statuses
|
111 |
+
)
|
112 |
+
)
|
113 |
+
));
|
114 |
+
return $this;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getRowUrl($row)
|
118 |
+
{
|
119 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
120 |
+
}
|
121 |
+
|
122 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Block.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Customfield_Block_Adminhtml_Block extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_block';
|
7 |
+
$this->_blockGroup = 'customfield';
|
8 |
+
$this->_headerText = Mage::helper('customfield')->__('Block Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('customfield')->__('Add Block');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Edit.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Block_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'customfield';
|
11 |
+
$this->_controller = 'adminhtml_block';
|
12 |
+
|
13 |
+
|
14 |
+
$this->_addButton('saveandcontinue', array(
|
15 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
16 |
+
'onclick' => 'saveAndContinueEdit()',
|
17 |
+
'class' => 'save',
|
18 |
+
), -100);
|
19 |
+
|
20 |
+
$this->_removeButton('save');
|
21 |
+
$this->_removeButton('back');
|
22 |
+
$this->_removeButton('delete');
|
23 |
+
$this->_removeButton('reset');
|
24 |
+
|
25 |
+
$this->_formScripts[] = "
|
26 |
+
function toggleEditor() {
|
27 |
+
if (tinyMCE.getInstanceById('customfield_content') == null) {
|
28 |
+
tinyMCE.execCommand('mceAddControl', false, 'customfield_content');
|
29 |
+
} else {
|
30 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'customfield_content');
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
function saveAndContinueEdit(){
|
35 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
36 |
+
}
|
37 |
+
";
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getHeaderText()
|
41 |
+
{
|
42 |
+
if( Mage::registry('block_data') && Mage::registry('block_data')->getId() ) {
|
43 |
+
return Mage::helper('customfield')->__("Edit Block Content");
|
44 |
+
} else {
|
45 |
+
return Mage::helper('customfield')->__('Add Block');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Block_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Block_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('block_form', array('legend'=>Mage::helper('customfield')->__('Block information')));
|
10 |
+
|
11 |
+
$fieldset->addField('content', 'editor', array(
|
12 |
+
'name' => 'content',
|
13 |
+
'label' => Mage::helper('customfield')->__('Content'),
|
14 |
+
'title' => Mage::helper('customfield')->__('Content'),
|
15 |
+
'style' => 'width:700px; height:500px;',
|
16 |
+
'wysiwyg' => false,
|
17 |
+
'required' => true,
|
18 |
+
));
|
19 |
+
|
20 |
+
if ( Mage::getSingleton('adminhtml/session')->getBlockData() )
|
21 |
+
{
|
22 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getBlockData());
|
23 |
+
Mage::getSingleton('adminhtml/session')->setBlockData(null);
|
24 |
+
} elseif ( Mage::registry('block_data') ) {
|
25 |
+
$form->setValues(Mage::registry('block_data')->getData());
|
26 |
+
}
|
27 |
+
return parent::_prepareForm();
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Block_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('block_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('customfield')->__('Block Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('customfield')->__('Block Information'),
|
18 |
+
'title' => Mage::helper('customfield')->__('Block Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('customfield/adminhtml_block_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Block/Grid.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Block_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('blockGrid');
|
9 |
+
$this->setDefaultSort('id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('customfield/block')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('id', array(
|
24 |
+
'header' => Mage::helper('customfield')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('name', array(
|
31 |
+
'header' => Mage::helper('customfield')->__('Name'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'name',
|
34 |
+
));
|
35 |
+
|
36 |
+
$this->addColumn('ordering', array(
|
37 |
+
'header' => Mage::helper('customfield')->__('Ordering'),
|
38 |
+
'align' =>'left',
|
39 |
+
'index' => 'ordering',
|
40 |
+
));
|
41 |
+
|
42 |
+
$this->addColumn('status', array(
|
43 |
+
'header' => Mage::helper('customfield')->__('Status'),
|
44 |
+
'align' => 'left',
|
45 |
+
'width' => '80px',
|
46 |
+
'index' => 'status',
|
47 |
+
'type' => 'options',
|
48 |
+
'options' => array(
|
49 |
+
1 => 'Enabled',
|
50 |
+
2 => 'Disabled',
|
51 |
+
),
|
52 |
+
));
|
53 |
+
|
54 |
+
$this->addColumn('action',
|
55 |
+
array(
|
56 |
+
'header' => Mage::helper('customfield')->__('Action'),
|
57 |
+
'width' => '100',
|
58 |
+
'type' => 'action',
|
59 |
+
'getter' => 'getId',
|
60 |
+
'actions' => array(
|
61 |
+
array(
|
62 |
+
'caption' => Mage::helper('customfield')->__('Edit'),
|
63 |
+
'url' => array('base'=> '*/*/edit'),
|
64 |
+
'field' => 'id'
|
65 |
+
)
|
66 |
+
),
|
67 |
+
'filter' => false,
|
68 |
+
'sortable' => false,
|
69 |
+
'index' => 'stores',
|
70 |
+
'is_system' => true,
|
71 |
+
));
|
72 |
+
|
73 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('customfield')->__('CSV'));
|
74 |
+
$this->addExportType('*/*/exportXml', Mage::helper('customfield')->__('XML'));
|
75 |
+
|
76 |
+
return parent::_prepareColumns();
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function _prepareMassaction()
|
80 |
+
{
|
81 |
+
$this->setMassactionIdField('customfield_id');
|
82 |
+
$this->getMassactionBlock()->setFormFieldName('customfield');
|
83 |
+
|
84 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
85 |
+
'label' => Mage::helper('customfield')->__('Delete'),
|
86 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
87 |
+
'confirm' => Mage::helper('customfield')->__('Are you sure?')
|
88 |
+
));
|
89 |
+
|
90 |
+
$statuses = Mage::getSingleton('customfield/status')->getOptionArray();
|
91 |
+
|
92 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
93 |
+
$this->getMassactionBlock()->addItem('status', array(
|
94 |
+
'label'=> Mage::helper('customfield')->__('Change status'),
|
95 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
96 |
+
'additional' => array(
|
97 |
+
'visibility' => array(
|
98 |
+
'name' => 'status',
|
99 |
+
'type' => 'select',
|
100 |
+
'class' => 'required-entry',
|
101 |
+
'label' => Mage::helper('customfield')->__('Status'),
|
102 |
+
'values' => $statuses
|
103 |
+
)
|
104 |
+
)
|
105 |
+
));
|
106 |
+
return $this;
|
107 |
+
}
|
108 |
+
|
109 |
+
public function getRowUrl($row)
|
110 |
+
{
|
111 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
112 |
+
}
|
113 |
+
|
114 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Catalog/Product/Edit/Tabs.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* admin product edit tabs
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Magestore_Customfield_Block_Adminhtml_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
|
35 |
+
{
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
protected function _prepareLayout()
|
41 |
+
{
|
42 |
+
$product = $this->getProduct();
|
43 |
+
|
44 |
+
if (!($setId = $product->getAttributeSetId())) {
|
45 |
+
$setId = $this->getRequest()->getParam('set', null);
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($setId) {
|
49 |
+
$groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
|
50 |
+
->setAttributeSetFilter($setId)
|
51 |
+
->load();
|
52 |
+
|
53 |
+
foreach ($groupCollection as $group) {
|
54 |
+
$attributes = $product->getAttributes($group->getId(), true);
|
55 |
+
// do not add grops without attributes
|
56 |
+
|
57 |
+
foreach ($attributes as $key => $attribute) {
|
58 |
+
if( !$attribute->getIsVisible() ) {
|
59 |
+
unset($attributes[$key]);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
if (count($attributes)==0) {
|
64 |
+
continue;
|
65 |
+
}
|
66 |
+
|
67 |
+
$this->addTab('group_'.$group->getId(), array(
|
68 |
+
'label' => Mage::helper('catalog')->__($group->getAttributeGroupName()),
|
69 |
+
'content' => $this->getLayout()->createBlock($this->getAttributeTabBlock())
|
70 |
+
->setGroup($group)
|
71 |
+
->setGroupAttributes($attributes)
|
72 |
+
->toHtml(),
|
73 |
+
));
|
74 |
+
}
|
75 |
+
|
76 |
+
$this->addTab('inventory', array(
|
77 |
+
'label' => Mage::helper('catalog')->__('Inventory'),
|
78 |
+
'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_inventory')->toHtml(),
|
79 |
+
));
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Don't display website tab for single mode
|
84 |
+
*/
|
85 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
86 |
+
$this->addTab('websites', array(
|
87 |
+
'label' => Mage::helper('catalog')->__('Websites'),
|
88 |
+
'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_websites')->toHtml(),
|
89 |
+
));
|
90 |
+
}
|
91 |
+
|
92 |
+
$this->addTab('categories', array(
|
93 |
+
'label' => Mage::helper('catalog')->__('Categories'),
|
94 |
+
'url' => $this->getUrl('*/*/categories', array('_current' => true)),
|
95 |
+
'class' => 'ajax',
|
96 |
+
));
|
97 |
+
|
98 |
+
$this->addTab('related', array(
|
99 |
+
'label' => Mage::helper('catalog')->__('Related Products'),
|
100 |
+
'url' => $this->getUrl('*/*/related', array('_current' => true)),
|
101 |
+
'class' => 'ajax',
|
102 |
+
));
|
103 |
+
|
104 |
+
$this->addTab('upsell', array(
|
105 |
+
'label' => Mage::helper('catalog')->__('Up-sells'),
|
106 |
+
'url' => $this->getUrl('*/*/upsell', array('_current' => true)),
|
107 |
+
'class' => 'ajax',
|
108 |
+
));
|
109 |
+
|
110 |
+
$this->addTab('crosssell', array(
|
111 |
+
'label' => Mage::helper('catalog')->__('Cross-sells'),
|
112 |
+
'url' => $this->getUrl('*/*/crosssell', array('_current' => true)),
|
113 |
+
'class' => 'ajax',
|
114 |
+
));
|
115 |
+
|
116 |
+
$storeId = 0;
|
117 |
+
if ($this->getRequest()->getParam('store')) {
|
118 |
+
$storeId = Mage::app()->getStore($this->getRequest()->getParam('store'))->getId();
|
119 |
+
}
|
120 |
+
|
121 |
+
$alertPriceAllow = Mage::getStoreConfig('catalog/productalert/allow_price');
|
122 |
+
$alertStockAllow = Mage::getStoreConfig('catalog/productalert/allow_stock');
|
123 |
+
|
124 |
+
if ($alertPriceAllow || $alertStockAllow) {
|
125 |
+
$this->addTab('productalert', array(
|
126 |
+
'label' => Mage::helper('catalog')->__('Product Alerts'),
|
127 |
+
'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_alerts', 'admin.alerts.products')->toHtml()
|
128 |
+
));
|
129 |
+
}
|
130 |
+
|
131 |
+
if( $this->getRequest()->getParam('id', false) ) {
|
132 |
+
$this->addTab('reviews', array(
|
133 |
+
'label' => Mage::helper('catalog')->__('Product Reviews'),
|
134 |
+
'url' => $this->getUrl('*/*/reviews', array('_current' => true)),
|
135 |
+
'class' => 'ajax',
|
136 |
+
));
|
137 |
+
|
138 |
+
$this->addTab('tags', array(
|
139 |
+
'label' => Mage::helper('catalog')->__('Product Tags'),
|
140 |
+
'url' => $this->getUrl('*/*/tagGrid', array('_current' => true)),
|
141 |
+
'class' => 'ajax',
|
142 |
+
));
|
143 |
+
|
144 |
+
$this->addTab('customers_tags', array(
|
145 |
+
'label' => Mage::helper('catalog')->__('Customers Tagged Product'),
|
146 |
+
'url' => $this->getUrl('*/*/tagCustomerGrid', array('_current' => true)),
|
147 |
+
'class' => 'ajax',
|
148 |
+
));
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Do not change this tab id
|
153 |
+
* @see Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs_Configurable
|
154 |
+
* @see Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tabs
|
155 |
+
*/
|
156 |
+
if ($this->getProduct()->getTypeId() != Mage_Catalog_Model_Product_Type::TYPE_GROUPED) {
|
157 |
+
$this->addTab('customer_options', array(
|
158 |
+
'label' => Mage::helper('catalog')->__('Custom Options'),
|
159 |
+
'url' => $this->getUrl('*/*/options', array('_current' => true)),
|
160 |
+
'class' => 'ajax',
|
161 |
+
));
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
165 |
+
else {
|
166 |
+
$this->addTab('set', array(
|
167 |
+
'label' => Mage::helper('catalog')->__('Settings'),
|
168 |
+
'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_settings')->toHtml(),
|
169 |
+
'active' => true
|
170 |
+
));
|
171 |
+
}
|
172 |
+
|
173 |
+
$this->addTab('customfield', array(
|
174 |
+
'label' => Mage::helper('catalog')->__('Custom Fields'),
|
175 |
+
'content' => $this->getLayout()->createBlock('customfield/adminhtml_attribute_edit_tab_customfield')->toHtml(),
|
176 |
+
'active' => false
|
177 |
+
));
|
178 |
+
return parent::_prepareLayout();
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Retrive product object from object if not from registry
|
183 |
+
*
|
184 |
+
* @return Mage_Catalog_Model_Product
|
185 |
+
*/
|
186 |
+
|
187 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Customfield_Block_Adminhtml_Customfield extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_customfield';
|
7 |
+
$this->_blockGroup = 'customfield';
|
8 |
+
$this->_headerText = Mage::helper('customfield')->__('Item Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('customfield')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Customfield_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'customfield';
|
11 |
+
$this->_controller = 'adminhtml_customfield';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('customfield')->__('Save Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('customfield')->__('Delete Item'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('customfield_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'customfield_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'customfield_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('customfield_data') && Mage::registry('customfield_data')->getId() ) {
|
40 |
+
return Mage::helper('customfield')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('customfield_data')->getTitle()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('customfield')->__('Add Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Customfield_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Customfield_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('customfield_form', array('legend'=>Mage::helper('customfield')->__('Item information')));
|
10 |
+
|
11 |
+
$fieldset->addField('title', 'text', array(
|
12 |
+
'label' => Mage::helper('customfield')->__('Title'),
|
13 |
+
'class' => 'required-entry',
|
14 |
+
'required' => true,
|
15 |
+
'name' => 'title',
|
16 |
+
));
|
17 |
+
|
18 |
+
$fieldset->addField('filename', 'file', array(
|
19 |
+
'label' => Mage::helper('customfield')->__('File'),
|
20 |
+
'required' => false,
|
21 |
+
'name' => 'filename',
|
22 |
+
));
|
23 |
+
|
24 |
+
$fieldset->addField('status', 'select', array(
|
25 |
+
'label' => Mage::helper('customfield')->__('Status'),
|
26 |
+
'name' => 'status',
|
27 |
+
'values' => array(
|
28 |
+
array(
|
29 |
+
'value' => 1,
|
30 |
+
'label' => Mage::helper('customfield')->__('Enabled'),
|
31 |
+
),
|
32 |
+
|
33 |
+
array(
|
34 |
+
'value' => 2,
|
35 |
+
'label' => Mage::helper('customfield')->__('Disabled'),
|
36 |
+
),
|
37 |
+
),
|
38 |
+
));
|
39 |
+
|
40 |
+
$fieldset->addField('content', 'editor', array(
|
41 |
+
'name' => 'content',
|
42 |
+
'label' => Mage::helper('customfield')->__('Content'),
|
43 |
+
'title' => Mage::helper('customfield')->__('Content'),
|
44 |
+
'style' => 'width:700px; height:500px;',
|
45 |
+
'wysiwyg' => false,
|
46 |
+
'required' => true,
|
47 |
+
));
|
48 |
+
|
49 |
+
if ( Mage::getSingleton('adminhtml/session')->getCustomfieldData() )
|
50 |
+
{
|
51 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getCustomfieldData());
|
52 |
+
Mage::getSingleton('adminhtml/session')->setCustomfieldData(null);
|
53 |
+
} elseif ( Mage::registry('customfield_data') ) {
|
54 |
+
$form->setValues(Mage::registry('customfield_data')->getData());
|
55 |
+
}
|
56 |
+
return parent::_prepareForm();
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Customfield_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('customfield_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('customfield')->__('Item Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('customfield')->__('Item Information'),
|
18 |
+
'title' => Mage::helper('customfield')->__('Item Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('customfield/adminhtml_customfield_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Magestore/Customfield/Block/Adminhtml/Customfield/Grid.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Block_Adminhtml_Customfield_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('customfieldGrid');
|
9 |
+
$this->setDefaultSort('customfield_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('customfield/customfield')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('customfield_id', array(
|
24 |
+
'header' => Mage::helper('customfield')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'customfield_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('title', array(
|
31 |
+
'header' => Mage::helper('customfield')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'title',
|
34 |
+
));
|
35 |
+
|
36 |
+
/*
|
37 |
+
$this->addColumn('content', array(
|
38 |
+
'header' => Mage::helper('customfield')->__('Item Content'),
|
39 |
+
'width' => '150px',
|
40 |
+
'index' => 'content',
|
41 |
+
));
|
42 |
+
*/
|
43 |
+
|
44 |
+
$this->addColumn('status', array(
|
45 |
+
'header' => Mage::helper('customfield')->__('Status'),
|
46 |
+
'align' => 'left',
|
47 |
+
'width' => '80px',
|
48 |
+
'index' => 'status',
|
49 |
+
'type' => 'options',
|
50 |
+
'options' => array(
|
51 |
+
1 => 'Enabled',
|
52 |
+
2 => 'Disabled',
|
53 |
+
),
|
54 |
+
));
|
55 |
+
|
56 |
+
$this->addColumn('action',
|
57 |
+
array(
|
58 |
+
'header' => Mage::helper('customfield')->__('Action'),
|
59 |
+
'width' => '100',
|
60 |
+
'type' => 'action',
|
61 |
+
'getter' => 'getId',
|
62 |
+
'actions' => array(
|
63 |
+
array(
|
64 |
+
'caption' => Mage::helper('customfield')->__('Edit'),
|
65 |
+
'url' => array('base'=> '*/*/edit'),
|
66 |
+
'field' => 'id'
|
67 |
+
)
|
68 |
+
),
|
69 |
+
'filter' => false,
|
70 |
+
'sortable' => false,
|
71 |
+
'index' => 'stores',
|
72 |
+
'is_system' => true,
|
73 |
+
));
|
74 |
+
|
75 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('customfield')->__('CSV'));
|
76 |
+
$this->addExportType('*/*/exportXml', Mage::helper('customfield')->__('XML'));
|
77 |
+
|
78 |
+
return parent::_prepareColumns();
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _prepareMassaction()
|
82 |
+
{
|
83 |
+
$this->setMassactionIdField('customfield_id');
|
84 |
+
$this->getMassactionBlock()->setFormFieldName('customfield');
|
85 |
+
|
86 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
87 |
+
'label' => Mage::helper('customfield')->__('Delete'),
|
88 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
89 |
+
'confirm' => Mage::helper('customfield')->__('Are you sure?')
|
90 |
+
));
|
91 |
+
|
92 |
+
$statuses = Mage::getSingleton('customfield/status')->getOptionArray();
|
93 |
+
|
94 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
95 |
+
$this->getMassactionBlock()->addItem('status', array(
|
96 |
+
'label'=> Mage::helper('customfield')->__('Change status'),
|
97 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
98 |
+
'additional' => array(
|
99 |
+
'visibility' => array(
|
100 |
+
'name' => 'status',
|
101 |
+
'type' => 'select',
|
102 |
+
'class' => 'required-entry',
|
103 |
+
'label' => Mage::helper('customfield')->__('Status'),
|
104 |
+
'values' => $statuses
|
105 |
+
)
|
106 |
+
)
|
107 |
+
));
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getRowUrl($row)
|
112 |
+
{
|
113 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
app/code/community/Magestore/Customfield/Block/Customfield.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Customfield_Block_Customfield extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getCustomBlockHtml()
|
10 |
+
{
|
11 |
+
$product_id = Mage::getSingleton('catalog/session')->getLastViewedProductId();
|
12 |
+
|
13 |
+
$attributeValues = Mage::getResourceSingleton("customfield/attributevalue")->getAttributeValues($product_id);
|
14 |
+
|
15 |
+
$block = Mage::getSingleton("customfield/block")->load(1);
|
16 |
+
$block_content = $block->getContent();
|
17 |
+
|
18 |
+
if($attributeValues)
|
19 |
+
{
|
20 |
+
foreach($attributeValues as $attributeValue)
|
21 |
+
{
|
22 |
+
$value = $attributeValue['value'];
|
23 |
+
$alias = $attributeValue['alias'];
|
24 |
+
$type = $attributeValue['type'];
|
25 |
+
$value = $this->getElementHtml($value,$type);
|
26 |
+
$block_content = str_replace("{".$alias."}",$value,$block_content);
|
27 |
+
}
|
28 |
+
$block_content = preg_replace("/{.*}/", "", $block_content );
|
29 |
+
}
|
30 |
+
else
|
31 |
+
{
|
32 |
+
$block_content = "";
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
return $block_content;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getElementHtml($value,$type)
|
42 |
+
{
|
43 |
+
|
44 |
+
$html ="";
|
45 |
+
switch($type)
|
46 |
+
{
|
47 |
+
case 'text':
|
48 |
+
$html = $value;
|
49 |
+
break;
|
50 |
+
case 'file':
|
51 |
+
|
52 |
+
$html = "<a target='_blank' href='". Mage::getBaseUrl("media") . "/catalog/customfield/" .$value ."'>" . $value . "</a>";
|
53 |
+
break;
|
54 |
+
}
|
55 |
+
|
56 |
+
return $html;
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
}
|
app/code/community/Magestore/Customfield/Helper/Data.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
public static function getBlockOptions()
|
6 |
+
{
|
7 |
+
$options = array();
|
8 |
+
$collection = Mage::getModel('customfield/block')->getCollection();
|
9 |
+
foreach($collection as $block)
|
10 |
+
{
|
11 |
+
$options[$block->getId()] = $block->getName();
|
12 |
+
}
|
13 |
+
return $options;
|
14 |
+
}
|
15 |
+
|
16 |
+
public static function getBlockOptions2()
|
17 |
+
{
|
18 |
+
$options = array();
|
19 |
+
$collection = Mage::getModel('customfield/block')->getCollection();
|
20 |
+
foreach($collection as $block)
|
21 |
+
{
|
22 |
+
$temp = array();
|
23 |
+
$temp['label'] = $block->getName();
|
24 |
+
$temp['value'] = $block->getId();
|
25 |
+
$options[] = $temp;
|
26 |
+
}
|
27 |
+
return $options;
|
28 |
+
}
|
29 |
+
|
30 |
+
public static function getCustomAttributeCode($custom_attribute_id)
|
31 |
+
{
|
32 |
+
return "customfield_".$custom_attribute_id;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getProductEntityTypeId()
|
36 |
+
{
|
37 |
+
//get entity_type_id
|
38 |
+
$entity_type = Mage::getSingleton("eav/entity_type")->loadByCode("catalog_product");
|
39 |
+
$entity_type_id = $entity_type->getId();
|
40 |
+
return $entity_type_id;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getAttributeId($attribute_code)
|
44 |
+
{
|
45 |
+
$attribute = Mage::getSingleton("eav/entity_attribute")->load($attribute_code,"attribute_code");
|
46 |
+
return $attribute->getId();
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getTablePrefix()
|
50 |
+
{
|
51 |
+
$tableName = Mage::getResourceModel('customfield/block')->getTable('block');
|
52 |
+
|
53 |
+
$prefix = str_replace('customfield_block','',$tableName);
|
54 |
+
|
55 |
+
return $prefix;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function upload_file($attibute_name)
|
59 |
+
{
|
60 |
+
|
61 |
+
//$new_file_name = $category_name.$this->getFileExtension($attibute_name);
|
62 |
+
|
63 |
+
$path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'customfield' . DS;
|
64 |
+
|
65 |
+
if(!is_dir($path))
|
66 |
+
{
|
67 |
+
mkdir($path);
|
68 |
+
chmod($path,0777);
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
try {
|
73 |
+
$uploader = new Varien_File_Uploader($attibute_name);
|
74 |
+
//$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
75 |
+
$uploader->setAllowRenameFiles(false);
|
76 |
+
$uploader->save($path);
|
77 |
+
|
78 |
+
$uploaded_name = $uploader->getUploadedFileName();
|
79 |
+
|
80 |
+
return $uploaded_name;
|
81 |
+
} catch (Exception $e) {
|
82 |
+
|
83 |
+
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
app/code/community/Magestore/Customfield/Model/Attribute.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Attribute extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('customfield/attribute');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function createProductAttribute()
|
12 |
+
{
|
13 |
+
try
|
14 |
+
{
|
15 |
+
//get entity_type_id
|
16 |
+
|
17 |
+
$entity_type_id = Mage::helper('customfield')->getProductEntityTypeId();
|
18 |
+
|
19 |
+
|
20 |
+
$attribute = Mage::getModel("eav/entity_attribute");
|
21 |
+
|
22 |
+
//create a sample attribute
|
23 |
+
$data = array();
|
24 |
+
|
25 |
+
//catcss_bgcolor
|
26 |
+
$data['id'] = null;
|
27 |
+
$data['entity_type_id'] = $entity_type_id;
|
28 |
+
$data['attribute_code'] = Mage::helper('customfield')->getCustomAttributeCode($this->getId());
|
29 |
+
$data['backend_type'] = "text";
|
30 |
+
$data['frontend_input'] = "text";
|
31 |
+
|
32 |
+
$attribute->setData($data);
|
33 |
+
$attribute->save();
|
34 |
+
|
35 |
+
}
|
36 |
+
catch (Mage_Core_Exception $e) {
|
37 |
+
$this->_getSession()->addError($e->getMessage());
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function deleteAttributeCode()
|
42 |
+
{
|
43 |
+
try
|
44 |
+
{
|
45 |
+
//get entity_type_id
|
46 |
+
|
47 |
+
$entity_type_id = Mage::helper('customfield')->getProductEntityTypeId();
|
48 |
+
|
49 |
+
$attribute_code = Mage::helper('customfield')->getCustomAttributeCode($this->getId());
|
50 |
+
$attribute = Mage::getModel("eav/entity_attribute")->load($attribute_code,"attribute_code");
|
51 |
+
$attribute->delete();
|
52 |
+
//create a sample attribute
|
53 |
+
$data = array();
|
54 |
+
}
|
55 |
+
catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_getSession()->addError($e->getMessage());
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
public function save_product_attribute($observer)
|
63 |
+
{
|
64 |
+
|
65 |
+
$observer_data = $observer->getData();
|
66 |
+
$request = $observer_data['request'];
|
67 |
+
$data = $request->getPost('customfield');
|
68 |
+
$product = $observer_data['product'];
|
69 |
+
|
70 |
+
$product_id = $product->getId();
|
71 |
+
if(!$product_id)
|
72 |
+
{
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
$customattributes = Mage::getModel("customfield/attribute")->getCollection();
|
77 |
+
$entity_type_id = Mage::helper('customfield')->getProductEntityTypeId();
|
78 |
+
foreach($customattributes as $customattribute)
|
79 |
+
{
|
80 |
+
$attribute_code = Mage::helper('customfield')->getCustomAttributeCode($customattribute->getId());
|
81 |
+
$attribute_id = Mage::helper('customfield')->getAttributeId($attribute_code);
|
82 |
+
$attribute_type = $customattribute->getType();
|
83 |
+
|
84 |
+
$value_id = Mage::getResourceSingleton("customfield/attributevalue")->getAttributeValueId(array('entity_type_id'=>$entity_type_id,'entity_id'=>$product_id,'attribute_id'=>$attribute_id));
|
85 |
+
$attributevalue = Mage::getSingleton("customfield/attributevalue")->load($value_id);
|
86 |
+
|
87 |
+
//set data
|
88 |
+
$attributevalue->setData("entity_type_id",$entity_type_id);
|
89 |
+
$attributevalue->setData("attribute_id",$attribute_id);
|
90 |
+
$attributevalue->setData("entity_id",$product_id);
|
91 |
+
|
92 |
+
switch($attribute_type)
|
93 |
+
{
|
94 |
+
case 'text':
|
95 |
+
$value = $data[$attribute_code];
|
96 |
+
$attributevalue->setData("value",$value);
|
97 |
+
break;
|
98 |
+
case 'file':
|
99 |
+
$value = Mage::helper('customfield')->upload_file("customfield[" . $attribute_code."]");
|
100 |
+
if($value)
|
101 |
+
$attributevalue->setData("value",$value);
|
102 |
+
break;
|
103 |
+
}
|
104 |
+
|
105 |
+
$attributevalue->save();
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
app/code/community/Magestore/Customfield/Model/Attributevalue.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Attributevalue extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('customfield/attributevalue');
|
9 |
+
}
|
10 |
+
|
11 |
+
|
12 |
+
}
|
app/code/community/Magestore/Customfield/Model/Block.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Block extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('customfield/block');
|
9 |
+
}
|
10 |
+
|
11 |
+
|
12 |
+
}
|
app/code/community/Magestore/Customfield/Model/Customfield.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Customfield extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('customfield/customfield');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Customfield/Model/Mysql4/Attribute.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Mysql4_Attribute extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the customfield_id refers to the key field in your database table.
|
8 |
+
$this->_init('customfield/attribute', 'id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Customfield/Model/Mysql4/Attribute/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Mysql4_Attribute_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('customfield/attribute');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Customfield/Model/Mysql4/Attributevalue.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Mysql4_Attributevalue extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the customfield_id refers to the key field in your database table.
|
8 |
+
$this->_init('customfield/attributevalue', 'value_id');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getAttributeValueId($data)
|
12 |
+
{
|
13 |
+
|
14 |
+
$select = $this->_getReadAdapter()->select()
|
15 |
+
->from($this->getMainTable())
|
16 |
+
->where($this->getMainTable().'.entity_type_id=?', $data['entity_type_id'])
|
17 |
+
->where($this->getMainTable().'.attribute_id=?', $data['attribute_id'])
|
18 |
+
->where($this->getMainTable().'.entity_id=?', $data['entity_id']);
|
19 |
+
|
20 |
+
$read = $this->_getReadAdapter();
|
21 |
+
$data = $read->fetchRow($select);
|
22 |
+
if($data)
|
23 |
+
{
|
24 |
+
return $data['value_id'];
|
25 |
+
}
|
26 |
+
return null;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getAttributeValues($product_id)
|
30 |
+
{
|
31 |
+
$entity_type_id = Mage::helper('customfield')->getProductEntityTypeId();
|
32 |
+
$eav_attribute_table = Mage::helper('customfield')->getTablePrefix() . "eav_attribute";
|
33 |
+
$custom_attribute_table = Mage::helper('customfield')->getTablePrefix() . "customfield_attribute";
|
34 |
+
|
35 |
+
$select = $this->_getReadAdapter()->select()
|
36 |
+
->from(array('eat'=>$this->getMainTable()))
|
37 |
+
->join(array('ea'=>$eav_attribute_table),'eat.attribute_id=ea.attribute_id',array('attribute_code'))
|
38 |
+
->join(array('ca'=>$custom_attribute_table),"ea.attribute_code=CONCAT('customfield_',ca.id)",array('type','alias'))
|
39 |
+
->where('eat.entity_type_id=?', $entity_type_id)
|
40 |
+
|
41 |
+
->where("ea.attribute_code like 'customfield_%'")
|
42 |
+
->where('eat.entity_id=?', $product_id);
|
43 |
+
|
44 |
+
$read = $this->_getReadAdapter();
|
45 |
+
$data = $read->fetchAll($select);
|
46 |
+
return $data;
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Magestore/Customfield/Model/Mysql4/Block.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Mysql4_Block extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the customfield_id refers to the key field in your database table.
|
8 |
+
$this->_init('customfield/block', 'id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Customfield/Model/Mysql4/Block/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Mysql4_Block_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('customfield/block');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Customfield/Model/Mysql4/Customfield.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Mysql4_Customfield extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the customfield_id refers to the key field in your database table.
|
8 |
+
$this->_init('customfield/customfield', 'customfield_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Customfield/Model/Mysql4/Customfield/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Mysql4_Customfield_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('customfield/customfield');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Customfield/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Model_Status extends Varien_Object
|
4 |
+
{
|
5 |
+
const STATUS_ENABLED = 1;
|
6 |
+
const STATUS_DISABLED = 2;
|
7 |
+
|
8 |
+
static public function getOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('customfield')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('customfield')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Magestore/Customfield/controllers/Adminhtml/AttributeController.php
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Adminhtml_AttributeController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('customfield/attributes')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Attributes Manager'), Mage::helper('adminhtml')->__('Attribute Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('customfield/attribute')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('attribute_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('customfield/attributes');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Attribute Manager'), Mage::helper('adminhtml')->__('Attribute Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Attribute News'), Mage::helper('adminhtml')->__('Attribute News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('customfield/adminhtml_attribute_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('customfield/adminhtml_attribute_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customfield')->__('Attribute does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
$model = Mage::getModel('customfield/attribute');
|
56 |
+
$model->setData($data)
|
57 |
+
->setId($this->getRequest()->getParam('id'));
|
58 |
+
|
59 |
+
try {
|
60 |
+
|
61 |
+
$model->save();
|
62 |
+
|
63 |
+
if(!$this->getRequest()->getParam('id'))
|
64 |
+
{
|
65 |
+
$model->createProductAttribute();
|
66 |
+
}
|
67 |
+
|
68 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customfield')->__('Attribute was successfully saved'));
|
69 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
70 |
+
|
71 |
+
if ($this->getRequest()->getParam('back')) {
|
72 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
$this->_redirect('*/*/');
|
76 |
+
return;
|
77 |
+
} catch (Exception $e) {
|
78 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
79 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
80 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customfield')->__('Unable to find attribute to save'));
|
85 |
+
$this->_redirect('*/*/');
|
86 |
+
}
|
87 |
+
|
88 |
+
public function deleteAction() {
|
89 |
+
$id = $this->getRequest()->getParam('id');
|
90 |
+
if( $id > 0 ) {
|
91 |
+
try {
|
92 |
+
$model = Mage::getModel('customfield/attribute');
|
93 |
+
|
94 |
+
Mage::getModel('customfield/attribute')->load($id)->deleteAttributeCode();
|
95 |
+
|
96 |
+
$model->setId($this->getRequest()->getParam('id'))
|
97 |
+
->delete();
|
98 |
+
|
99 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Attribute was successfully deleted'));
|
100 |
+
$this->_redirect('*/*/');
|
101 |
+
} catch (Exception $e) {
|
102 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
103 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
104 |
+
}
|
105 |
+
}
|
106 |
+
$this->_redirect('*/*/');
|
107 |
+
}
|
108 |
+
|
109 |
+
public function massDeleteAction() {
|
110 |
+
$attributeIds = $this->getRequest()->getParam('id');
|
111 |
+
if(!is_array($attributeIds)) {
|
112 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select attribute(s)'));
|
113 |
+
} else {
|
114 |
+
try {
|
115 |
+
foreach ($attributeIds as $attributeId) {
|
116 |
+
$attribute = Mage::getModel('customfield/attribute')->load($attributeId);
|
117 |
+
$attribute->delete();
|
118 |
+
}
|
119 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
120 |
+
Mage::helper('adminhtml')->__(
|
121 |
+
'Total of %d record(s) were successfully deleted', count($attributeIds)
|
122 |
+
)
|
123 |
+
);
|
124 |
+
} catch (Exception $e) {
|
125 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
126 |
+
}
|
127 |
+
}
|
128 |
+
$this->_redirect('*/*/index');
|
129 |
+
}
|
130 |
+
|
131 |
+
public function massStatusAction()
|
132 |
+
{
|
133 |
+
$attributeIds = $this->getRequest()->getParam('attribute');
|
134 |
+
if(!is_array($attributeIds)) {
|
135 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select attribute(s)'));
|
136 |
+
} else {
|
137 |
+
try {
|
138 |
+
foreach ($attributeIds as $attributeId) {
|
139 |
+
$attribute = Mage::getSingleton('customfield/attribute')
|
140 |
+
->load($attributeId)
|
141 |
+
->setStatus($this->getRequest()->getParam('status'))
|
142 |
+
->setIsMassupdate(true)
|
143 |
+
->save();
|
144 |
+
}
|
145 |
+
$this->_getSession()->addSuccess(
|
146 |
+
$this->__('Total of %d record(s) were successfully updated', count($attributeIds))
|
147 |
+
);
|
148 |
+
} catch (Exception $e) {
|
149 |
+
$this->_getSession()->addError($e->getMessage());
|
150 |
+
}
|
151 |
+
}
|
152 |
+
$this->_redirect('*/*/index');
|
153 |
+
}
|
154 |
+
|
155 |
+
public function exportCsvAction()
|
156 |
+
{
|
157 |
+
$fileName = 'attributes.csv';
|
158 |
+
$content = $this->getLayout()->createBlock('customfield/adminhtml_attribute_grid')
|
159 |
+
->getCsv();
|
160 |
+
|
161 |
+
$this->_sendUploadResponse($fileName, $content);
|
162 |
+
}
|
163 |
+
|
164 |
+
public function exportXmlAction()
|
165 |
+
{
|
166 |
+
$fileName = 'attributes.xml';
|
167 |
+
$content = $this->getLayout()->createBlock('customfield/adminhtml_attribute_grid')
|
168 |
+
->getXml();
|
169 |
+
|
170 |
+
$this->_sendUploadResponse($fileName, $content);
|
171 |
+
}
|
172 |
+
|
173 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
174 |
+
{
|
175 |
+
$response = $this->getResponse();
|
176 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
177 |
+
$response->setHeader('Pragma', 'public', true);
|
178 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
179 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
180 |
+
$response->setHeader('Last-Modified', date('r'));
|
181 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
182 |
+
$response->setHeader('Content-Length', strlen($content));
|
183 |
+
$response->setHeader('Content-type', $contentType);
|
184 |
+
$response->setBody($content);
|
185 |
+
$response->sendResponse();
|
186 |
+
die;
|
187 |
+
}
|
188 |
+
}
|
app/code/community/Magestore/Customfield/controllers/Adminhtml/BlockController.php
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Adminhtml_BlockController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('customfield/blocks')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Blocks Manager'), Mage::helper('adminhtml')->__('Block Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('customfield/block')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('block_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('customfield/blocks');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Block Manager'), Mage::helper('adminhtml')->__('Block Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Block News'), Mage::helper('adminhtml')->__('Block News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('customfield/adminhtml_block_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('customfield/adminhtml_block_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customfield')->__('Block does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
$model = Mage::getModel('customfield/block');
|
57 |
+
$model->setData($data)
|
58 |
+
->setId($this->getRequest()->getParam('id'));
|
59 |
+
|
60 |
+
try {
|
61 |
+
$model->save();
|
62 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customfield')->__('Block was successfully saved'));
|
63 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
64 |
+
|
65 |
+
if ($this->getRequest()->getParam('back')) {
|
66 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
$this->_redirect('*/*/');
|
70 |
+
return;
|
71 |
+
} catch (Exception $e) {
|
72 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
73 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
74 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customfield')->__('Unable to find block to save'));
|
79 |
+
$this->_redirect('*/*/');
|
80 |
+
}
|
81 |
+
|
82 |
+
public function deleteAction() {
|
83 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
84 |
+
try {
|
85 |
+
$model = Mage::getModel('customfield/block');
|
86 |
+
|
87 |
+
$model->setId($this->getRequest()->getParam('id'))
|
88 |
+
->delete();
|
89 |
+
|
90 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Block was successfully deleted'));
|
91 |
+
$this->_redirect('*/*/');
|
92 |
+
} catch (Exception $e) {
|
93 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
94 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
95 |
+
}
|
96 |
+
}
|
97 |
+
$this->_redirect('*/*/');
|
98 |
+
}
|
99 |
+
|
100 |
+
public function massDeleteAction() {
|
101 |
+
$blocks = $this->getRequest()->getParam('block');
|
102 |
+
if(!is_array($blocks)) {
|
103 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select block(s)'));
|
104 |
+
} else {
|
105 |
+
try {
|
106 |
+
foreach ($blocks as $id) {
|
107 |
+
$block = Mage::getModel('customfield/block')->load($id);
|
108 |
+
$block->delete();
|
109 |
+
}
|
110 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
111 |
+
Mage::helper('adminhtml')->__(
|
112 |
+
'Total of %d record(s) were successfully deleted', count($blocks)
|
113 |
+
)
|
114 |
+
);
|
115 |
+
} catch (Exception $e) {
|
116 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
117 |
+
}
|
118 |
+
}
|
119 |
+
$this->_redirect('*/*/index');
|
120 |
+
}
|
121 |
+
|
122 |
+
public function massStatusAction()
|
123 |
+
{
|
124 |
+
$blockIds = $this->getRequest()->getParam('id');
|
125 |
+
if(!is_array($blockIds)) {
|
126 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select block(s)'));
|
127 |
+
} else {
|
128 |
+
try {
|
129 |
+
foreach ($blockIds as $blockId) {
|
130 |
+
$block = Mage::getSingleton('customfield/block')
|
131 |
+
->load($blockId)
|
132 |
+
->setStatus($this->getRequest()->getParam('status'))
|
133 |
+
->setIsMassupdate(true)
|
134 |
+
->save();
|
135 |
+
}
|
136 |
+
$this->_getSession()->addSuccess(
|
137 |
+
$this->__('Total of %d record(s) were successfully updated', count($blockIds))
|
138 |
+
);
|
139 |
+
} catch (Exception $e) {
|
140 |
+
$this->_getSession()->addError($e->getMessage());
|
141 |
+
}
|
142 |
+
}
|
143 |
+
$this->_redirect('*/*/index');
|
144 |
+
}
|
145 |
+
|
146 |
+
public function exportCsvAction()
|
147 |
+
{
|
148 |
+
$fileName = 'blocks.csv';
|
149 |
+
$content = $this->getLayout()->createBlock('customfield/adminhtml_block_grid')
|
150 |
+
->getCsv();
|
151 |
+
|
152 |
+
$this->_sendUploadResponse($fileName, $content);
|
153 |
+
}
|
154 |
+
}
|
app/code/community/Magestore/Customfield/controllers/Adminhtml/CustomfieldController.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Customfield_Adminhtml_CustomfieldController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('customfield/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('customfield/customfield')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('customfield_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('customfield/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('customfield/adminhtml_customfield_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('customfield/adminhtml_customfield_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customfield')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
57 |
+
try {
|
58 |
+
/* Starting upload */
|
59 |
+
$uploader = new Varien_File_Uploader('filename');
|
60 |
+
|
61 |
+
// Any extention would work
|
62 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
63 |
+
$uploader->setAllowRenameFiles(false);
|
64 |
+
|
65 |
+
// Set the file upload mode
|
66 |
+
// false -> get the file directly in the specified folder
|
67 |
+
// true -> get the file in the product like folders
|
68 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
69 |
+
$uploader->setFilesDispersion(false);
|
70 |
+
|
71 |
+
// We set media as the upload dir
|
72 |
+
$path = Mage::getBaseDir('media') . DS ;
|
73 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
74 |
+
|
75 |
+
} catch (Exception $e) {
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
//this way the name is saved in DB
|
80 |
+
$data['filename'] = $_FILES['filename']['name'];
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
$model = Mage::getModel('customfield/customfield');
|
85 |
+
$model->setData($data)
|
86 |
+
->setId($this->getRequest()->getParam('id'));
|
87 |
+
|
88 |
+
try {
|
89 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
90 |
+
$model->setCreatedTime(now())
|
91 |
+
->setUpdateTime(now());
|
92 |
+
} else {
|
93 |
+
$model->setUpdateTime(now());
|
94 |
+
}
|
95 |
+
|
96 |
+
$model->save();
|
97 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customfield')->__('Item was successfully saved'));
|
98 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
99 |
+
|
100 |
+
if ($this->getRequest()->getParam('back')) {
|
101 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
$this->_redirect('*/*/');
|
105 |
+
return;
|
106 |
+
} catch (Exception $e) {
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
108 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
109 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customfield')->__('Unable to find item to save'));
|
114 |
+
$this->_redirect('*/*/');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function deleteAction() {
|
118 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
119 |
+
try {
|
120 |
+
$model = Mage::getModel('customfield/customfield');
|
121 |
+
|
122 |
+
$model->setId($this->getRequest()->getParam('id'))
|
123 |
+
->delete();
|
124 |
+
|
125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
} catch (Exception $e) {
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
129 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$this->_redirect('*/*/');
|
133 |
+
}
|
134 |
+
|
135 |
+
public function massDeleteAction() {
|
136 |
+
$customfieldIds = $this->getRequest()->getParam('customfield');
|
137 |
+
if(!is_array($customfieldIds)) {
|
138 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
139 |
+
} else {
|
140 |
+
try {
|
141 |
+
foreach ($customfieldIds as $customfieldId) {
|
142 |
+
$customfield = Mage::getModel('customfield/customfield')->load($customfieldId);
|
143 |
+
$customfield->delete();
|
144 |
+
}
|
145 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
146 |
+
Mage::helper('adminhtml')->__(
|
147 |
+
'Total of %d record(s) were successfully deleted', count($customfieldIds)
|
148 |
+
)
|
149 |
+
);
|
150 |
+
} catch (Exception $e) {
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
152 |
+
}
|
153 |
+
}
|
154 |
+
$this->_redirect('*/*/index');
|
155 |
+
}
|
156 |
+
|
157 |
+
public function massStatusAction()
|
158 |
+
{
|
159 |
+
$customfieldIds = $this->getRequest()->getParam('customfield');
|
160 |
+
if(!is_array($customfieldIds)) {
|
161 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
162 |
+
} else {
|
163 |
+
try {
|
164 |
+
foreach ($customfieldIds as $customfieldId) {
|
165 |
+
$customfield = Mage::getSingleton('customfield/customfield')
|
166 |
+
->load($customfieldId)
|
167 |
+
->setStatus($this->getRequest()->getParam('status'))
|
168 |
+
->setIsMassupdate(true)
|
169 |
+
->save();
|
170 |
+
}
|
171 |
+
$this->_getSession()->addSuccess(
|
172 |
+
$this->__('Total of %d record(s) were successfully updated', count($customfieldIds))
|
173 |
+
);
|
174 |
+
} catch (Exception $e) {
|
175 |
+
$this->_getSession()->addError($e->getMessage());
|
176 |
+
}
|
177 |
+
}
|
178 |
+
$this->_redirect('*/*/index');
|
179 |
+
}
|
180 |
+
|
181 |
+
public function exportCsvAction()
|
182 |
+
{
|
183 |
+
$fileName = 'customfield.csv';
|
184 |
+
$content = $this->getLayout()->createBlock('customfield/adminhtml_customfield_grid')
|
185 |
+
->getCsv();
|
186 |
+
|
187 |
+
$this->_sendUploadResponse($fileName, $content);
|
188 |
+
}
|
189 |
+
|
190 |
+
public function exportXmlAction()
|
191 |
+
{
|
192 |
+
$fileName = 'customfield.xml';
|
193 |
+
$content = $this->getLayout()->createBlock('customfield/adminhtml_customfield_grid')
|
194 |
+
->getXml();
|
195 |
+
|
196 |
+
$this->_sendUploadResponse($fileName, $content);
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
200 |
+
{
|
201 |
+
$response = $this->getResponse();
|
202 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
203 |
+
$response->setHeader('Pragma', 'public', true);
|
204 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
205 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
206 |
+
$response->setHeader('Last-Modified', date('r'));
|
207 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
208 |
+
$response->setHeader('Content-Length', strlen($content));
|
209 |
+
$response->setHeader('Content-type', $contentType);
|
210 |
+
$response->setBody($content);
|
211 |
+
$response->sendResponse();
|
212 |
+
die;
|
213 |
+
}
|
214 |
+
}
|
app/code/community/Magestore/Customfield/controllers/IndexController.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Customfield_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
|
7 |
+
/*
|
8 |
+
* Load an object by id
|
9 |
+
* Request looking like:
|
10 |
+
* http://site.com/customfield?id=15
|
11 |
+
* or
|
12 |
+
* http://site.com/customfield/id/15
|
13 |
+
*/
|
14 |
+
/*
|
15 |
+
$customfield_id = $this->getRequest()->getParam('id');
|
16 |
+
|
17 |
+
if($customfield_id != null && $customfield_id != '') {
|
18 |
+
$customfield = Mage::getModel('customfield/customfield')->load($customfield_id)->getData();
|
19 |
+
} else {
|
20 |
+
$customfield = null;
|
21 |
+
}
|
22 |
+
*/
|
23 |
+
|
24 |
+
/*
|
25 |
+
* If no param we load a the last created item
|
26 |
+
*/
|
27 |
+
/*
|
28 |
+
if($customfield == null) {
|
29 |
+
$resource = Mage::getSingleton('core/resource');
|
30 |
+
$read= $resource->getConnection('core_read');
|
31 |
+
$customfieldTable = $resource->getTableName('customfield');
|
32 |
+
|
33 |
+
$select = $read->select()
|
34 |
+
->from($customfieldTable,array('customfield_id','title','content','status'))
|
35 |
+
->where('status',1)
|
36 |
+
->order('created_time DESC') ;
|
37 |
+
|
38 |
+
$customfield = $read->fetchRow($select);
|
39 |
+
}
|
40 |
+
Mage::register('customfield', $customfield);
|
41 |
+
*/
|
42 |
+
|
43 |
+
|
44 |
+
$this->loadLayout();
|
45 |
+
$this->renderLayout();
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Magestore/Customfield/etc/config.xml
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Magestore_Customfield>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Magestore_Customfield>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<customfield>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Magestore_Customfield</module>
|
14 |
+
<frontName>customfield</frontName>
|
15 |
+
</args>
|
16 |
+
</customfield>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<customfield>
|
21 |
+
<file>customfield.xml</file>
|
22 |
+
</customfield>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<customfield>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Magestore_Customfield</module>
|
32 |
+
<frontName>customfield</frontName>
|
33 |
+
</args>
|
34 |
+
</customfield>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<events>
|
39 |
+
|
40 |
+
<catalog_product_prepare_save>
|
41 |
+
<observers>
|
42 |
+
<magestore_customfield_observer>
|
43 |
+
<type>singleton</type>
|
44 |
+
<class>customfield/attribute</class>
|
45 |
+
<method>save_product_attribute</method>
|
46 |
+
</magestore_customfield_observer>
|
47 |
+
</observers>
|
48 |
+
</catalog_product_prepare_save>
|
49 |
+
</events>
|
50 |
+
<menu>
|
51 |
+
<customfield module="customfield">
|
52 |
+
<title>Customfield</title>
|
53 |
+
<sort_order>71</sort_order>
|
54 |
+
<children>
|
55 |
+
<blocks module="customfield">
|
56 |
+
<title>Manage Blocks</title>
|
57 |
+
<sort_order>0</sort_order>
|
58 |
+
<action>customfield/adminhtml_block/edit/id/1</action>
|
59 |
+
</blocks>
|
60 |
+
|
61 |
+
<attributes module="customfield">
|
62 |
+
<title>Manage Attributes</title>
|
63 |
+
<sort_order>0</sort_order>
|
64 |
+
<action>customfield/adminhtml_attribute</action>
|
65 |
+
</attributes>
|
66 |
+
</children>
|
67 |
+
</customfield>
|
68 |
+
</menu>
|
69 |
+
<acl>
|
70 |
+
<resources>
|
71 |
+
<all>
|
72 |
+
<title>Allow Everything</title>
|
73 |
+
</all>
|
74 |
+
<admin>
|
75 |
+
<children>
|
76 |
+
<Magestore_Customfield>
|
77 |
+
<title>Customfield Module</title>
|
78 |
+
<sort_order>10</sort_order>
|
79 |
+
</Magestore_Customfield>
|
80 |
+
</children>
|
81 |
+
</admin>
|
82 |
+
</resources>
|
83 |
+
</acl>
|
84 |
+
<layout>
|
85 |
+
<updates>
|
86 |
+
<customfield>
|
87 |
+
<file>customfield.xml</file>
|
88 |
+
</customfield>
|
89 |
+
</updates>
|
90 |
+
</layout>
|
91 |
+
</adminhtml>
|
92 |
+
<global>
|
93 |
+
<models>
|
94 |
+
<customfield>
|
95 |
+
<class>Magestore_Customfield_Model</class>
|
96 |
+
<resourceModel>customfield_mysql4</resourceModel>
|
97 |
+
</customfield>
|
98 |
+
<customfield_mysql4>
|
99 |
+
<class>Magestore_Customfield_Model_Mysql4</class>
|
100 |
+
<entities>
|
101 |
+
<block>
|
102 |
+
<table>customfield_block</table>
|
103 |
+
</block>
|
104 |
+
|
105 |
+
<attribute>
|
106 |
+
<table>customfield_attribute</table>
|
107 |
+
</attribute>
|
108 |
+
|
109 |
+
<attributevalue>
|
110 |
+
<table>catalog_product_entity_text</table>
|
111 |
+
</attributevalue>
|
112 |
+
</entities>
|
113 |
+
</customfield_mysql4>
|
114 |
+
</models>
|
115 |
+
<resources>
|
116 |
+
<customfield_setup>
|
117 |
+
<setup>
|
118 |
+
<module>Magestore_Customfield</module>
|
119 |
+
</setup>
|
120 |
+
<connection>
|
121 |
+
<use>core_setup</use>
|
122 |
+
</connection>
|
123 |
+
</customfield_setup>
|
124 |
+
<customfield_write>
|
125 |
+
<connection>
|
126 |
+
<use>core_write</use>
|
127 |
+
</connection>
|
128 |
+
</customfield_write>
|
129 |
+
<customfield_read>
|
130 |
+
<connection>
|
131 |
+
<use>core_read</use>
|
132 |
+
</connection>
|
133 |
+
</customfield_read>
|
134 |
+
</resources>
|
135 |
+
<blocks>
|
136 |
+
<customfield>
|
137 |
+
<class>Magestore_Customfield_Block</class>
|
138 |
+
</customfield>
|
139 |
+
|
140 |
+
<adminhtml>
|
141 |
+
<rewrite>
|
142 |
+
<catalog_product_edit_tabs>Magestore_Customfield_Block_Adminhtml_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
|
143 |
+
</rewrite>
|
144 |
+
</adminhtml>
|
145 |
+
</blocks>
|
146 |
+
<helpers>
|
147 |
+
<customfield>
|
148 |
+
<class>Magestore_Customfield_Helper</class>
|
149 |
+
</customfield>
|
150 |
+
</helpers>
|
151 |
+
</global>
|
152 |
+
</config>
|
app/code/community/Magestore/Customfield/sql/customfield_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
DROP TABLE IF EXISTS {$this->getTable('customfield_attribute')};
|
9 |
+
CREATE TABLE {$this->getTable('customfield_attribute')} (
|
10 |
+
`id` int(11) NOT NULL auto_increment,
|
11 |
+
`type` varchar(50) default NULL,
|
12 |
+
`name` varchar(50) NOT NULL,
|
13 |
+
`alias` varchar(50) default NULL,
|
14 |
+
PRIMARY KEY (`id`)
|
15 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
|
16 |
+
|
17 |
+
DROP TABLE IF EXISTS {$this->getTable('customfield_block')};
|
18 |
+
CREATE TABLE {$this->getTable('customfield_block')} (
|
19 |
+
`id` int(11) NOT NULL auto_increment,
|
20 |
+
`content` text NOT NULL,
|
21 |
+
PRIMARY KEY (`id`)
|
22 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
23 |
+
|
24 |
+
INSERT INTO `customfield_block` VALUES (1, '');
|
25 |
+
|
26 |
+
|
27 |
+
");
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/customfield.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<customfield_adminhtml_block_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="customfield/adminhtml_block" name="block" />
|
6 |
+
</reference>
|
7 |
+
</customfield_adminhtml_block_index>
|
8 |
+
|
9 |
+
<customfield_adminhtml_attribute_index>
|
10 |
+
<reference name="content">
|
11 |
+
<block type="customfield/adminhtml_attribute" name="attribute" />
|
12 |
+
</reference>
|
13 |
+
</customfield_adminhtml_attribute_index>
|
14 |
+
</layout>
|
app/design/frontend/default/default/layout/customfield.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
</default>
|
5 |
+
<customfield_index_index>
|
6 |
+
<reference name="content">
|
7 |
+
<block type="customfield/customfield" name="customfield" template="customfield/customfield.phtml" />
|
8 |
+
</reference>
|
9 |
+
</customfield_index_index>
|
10 |
+
|
11 |
+
<catalog_product_view>
|
12 |
+
<update handle="product.info.additional" />
|
13 |
+
<reference name="product.info.additional">
|
14 |
+
<block type="customfield/customfield" name="customfield" template="customfield/customfield.phtml" />
|
15 |
+
</reference>
|
16 |
+
</catalog_product_view>
|
17 |
+
</layout>
|
app/design/frontend/default/default/template/customfield/customfield.phtml
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
echo($this->getCustomBlockHtml());
|
3 |
+
?>
|
app/etc/modules/Magestore_Customfield.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Magestore_Customfield>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Magestore_Customfield>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>CustomField</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>In some case you want to add some additional text for downloadable link file into product page such as user manual for your product.</summary>
|
10 |
+
<description>In some case you want to add some additional text for downloadable link file into product page such as user manual for your product. You want to have an ability to upload those files in product page in admin section and show them on the frontend as a download link. Magento doesn’t support that feature. How can we do that?
|
11 |
+
Our “Custom Field” extension solved the problem perfectly. With “Custom Field”, you can:
|
12 |
+
- Create file or text as much as you need.
|
13 |
+
- Design the look </description>
|
14 |
+
<notes>In some case you want to add some additional text for downloadable link file into product page such as user manual for your product.</notes>
|
15 |
+
<authors><author><name>Magestore</name><user>auto-converted</user><email>magestore@gmail.com</email></author></authors>
|
16 |
+
<date>2009-11-28</date>
|
17 |
+
<time>01:53:01</time>
|
18 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customfield.xml" hash="897b959554a8641f895b9bec8410b64e"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="customfield.xml" hash="c2e960b6b256a490239da9ed017c812e"/></dir><dir name="template"><dir name="customfield"><file name="customfield.phtml" hash="58618fb87649b156adb4480fba5fa1a1"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Magestore"><dir name="Customfield"><dir name="Block"><file name="Customfield.php" hash="26c06bb64f9a8bbc5d269ff7b9ed87b9"/><dir name="Adminhtml"><file name="Attribute.php" hash="ca493edb2997f42633eeaddf5020b999"/><file name="Block.php" hash="9fc9760621085b5c239dbdd9889c9277"/><file name="Customfield.php" hash="b06edb0615024c553820394d2b281ffa"/><dir name="Attribute"><file name="Edit.php" hash="211f4f2b17f5401598b506cb8e990a28"/><file name="Grid.php" hash="b90f8a48d6e7f0e4d431d856b74196d6"/><dir name="Edit"><file name="Form.php" hash="145219d581dbfab1af30ea309bdb8121"/><file name="Tabs.php" hash="f478945e083ed3aa92af588a257d8301"/><dir name="Tab"><file name="Customfield.php" hash="f85d22efeac916029f3510b129f2517b"/><file name="Form.php" hash="ca7450c55e821b7ac2b72b10b9e79ce4"/></dir></dir></dir><dir name="Block"><file name="Edit.php" hash="17443bd4ed805d6a22d827bc947c7b71"/><file name="Grid.php" hash="4298ff72a60bd6eb14138600711e8ee2"/><dir name="Edit"><file name="Form.php" hash="242e058b14df9aedbc4dfa60b4c598da"/><file name="Tabs.php" hash="05eb2fee093f452bf4579ce91b643b07"/><dir name="Tab"><file name="Form.php" hash="a29c90f12df274ad797945d1469599a9"/></dir></dir></dir><dir name="Catalog"><dir name="Product"><dir name="Edit"><file name="Tabs.php" hash="2ddf931f6d316a819016bebeb5ab071f"/></dir></dir></dir><dir name="Customfield"><file name="Edit.php" hash="e7529bdda028048a30fc65b3ed756907"/><file name="Grid.php" hash="54a8525cf9817b71881f5556d14a9758"/><dir name="Edit"><file name="Form.php" hash="89308799d8391b6b7ec78bf3dd459044"/><file name="Tabs.php" hash="6d4520331cf4564db39141f8cf1e1db8"/><dir name="Tab"><file name="Form.php" hash="40ae52f747bc886596e98eb70acf1a57"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="37ef75a0a562d4679f69c939284d3408"/><dir name="Adminhtml"><file name="AttributeController.php" hash="e52ef559adda4b277b41100a5b64d03d"/><file name="BlockController.php" hash="309c27391eddfc3b9735922c571a3f0c"/><file name="CustomfieldController.php" hash="55c2ef86263976bfe00238f5c74e777b"/></dir></dir><dir name="etc"><file name="config.xml" hash="384d660c474bbd01c09c9a43f4210fa8"/></dir><dir name="Helper"><file name="Data.php" hash="3b06226c97a06c1fdbc03f74376c7b63"/></dir><dir name="Model"><file name="Attribute.php" hash="c741b7cea74f5a3764664f2b52cdf52e"/><file name="Attributevalue.php" hash="4f2bb99a4a9281ecdc28e6ec64a42806"/><file name="Block.php" hash="29e4234bfa8009ddfd0405d8f1478e06"/><file name="Customfield.php" hash="70fb44f27d0916e3cd5b900cba958d3d"/><file name="Status.php" hash="53589f71955500482a9f471118c6420d"/><dir name="Mysql4"><file name="Attribute.php" hash="656189492a5b9b1739bb0a1b3d5fcc72"/><file name="Attributevalue.php" hash="1f5dfc8032fecedb50d0731daa8c4e95"/><file name="Block.php" hash="253f0c722ae6188676315c424b3dfab9"/><file name="Customfield.php" hash="334ee14646f1bd297007ef1240afe706"/><dir name="Attribute"><file name="Collection.php" hash="576b3356dbb77c31f5b93c7df5e62737"/></dir><dir name="Block"><file name="Collection.php" hash="e1e468c7fe776953625564bee1ab6446"/></dir><dir name="Customfield"><file name="Collection.php" hash="664427530330358e74db701b510dbe57"/></dir></dir></dir><dir name="sql"><dir name="customfield_setup"><file name="mysql4-install-0.1.0.php" hash="1414b2fbc9518e091927e635452f4fbc"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magestore_Customfield.xml" hash="f490edfa6a923b28e0fe56231ff74f4e"/></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies/>
|
21 |
+
</package>
|