Xt_Brand - Version 1.0.0

Version Notes

This extension is a stable version.

Download this release

Release Info

Developer Rik Sen
Extension Xt_Brand
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (28) hide show
  1. app/code/local/XT/Brand/Block/Adminhtml/Brand.php +12 -0
  2. app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit.php +47 -0
  3. app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Form.php +19 -0
  4. app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Tab/Form.php +49 -0
  5. app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Tab/Grid.php +209 -0
  6. app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Tab/Store.php +10 -0
  7. app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Tabs.php +36 -0
  8. app/code/local/XT/Brand/Block/Adminhtml/Brand/Grid.php +77 -0
  9. app/code/local/XT/Brand/Block/Brand.php +73 -0
  10. app/code/local/XT/Brand/Helper/Data.php +6 -0
  11. app/code/local/XT/Brand/Model/Brand.php +19 -0
  12. app/code/local/XT/Brand/Model/Grid.php +9 -0
  13. app/code/local/XT/Brand/Model/Mysql4/Brand.php +10 -0
  14. app/code/local/XT/Brand/Model/Mysql4/Brand/Collection.php +10 -0
  15. app/code/local/XT/Brand/Model/Mysql4/Grid.php +19 -0
  16. app/code/local/XT/Brand/Model/Mysql4/Grid/Collection.php +10 -0
  17. app/code/local/XT/Brand/controllers/Adminhtml/BrandController.php +236 -0
  18. app/code/local/XT/Brand/controllers/IndexController.php +9 -0
  19. app/code/local/XT/Brand/etc/config.xml +121 -0
  20. app/code/local/XT/Brand/sql/brand_setup/mysql4-install-0.1.0.php +36 -0
  21. app/design/adminhtml/default/default/layout/brand.xml +31 -0
  22. app/design/adminhtml/default/default/template/brand/stores.phtml +84 -0
  23. app/design/frontend/base/default/layout/brand.xml +20 -0
  24. app/design/frontend/base/default/template/brand/brand_left.phtml +11 -0
  25. app/design/frontend/base/default/template/brand/brand_list.phtml +20 -0
  26. app/design/frontend/base/default/template/brand/brand_products.phtml +108 -0
  27. app/etc/modules/XT_Brand.xml +9 -0
  28. package.xml +20 -0
app/code/local/XT/Brand/Block/Adminhtml/Brand.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class XT_Brand_Block_Adminhtml_Brand extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_brand';
7
+ $this->_blockGroup = 'brand';
8
+ $this->_headerText = Mage::helper('brand')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('brand')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Block_Adminhtml_Brand_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 = 'brand';
11
+ $this->_controller = 'adminhtml_brand';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('brand')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('brand')->__('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('brand_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'brand_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'brand_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ $this->_removeButton('save');
36
+ $this->_removeButton('delete');
37
+ }
38
+
39
+ public function getHeaderText()
40
+ {
41
+ if( Mage::registry('brand_data') && Mage::registry('brand_data')->getId() ) {
42
+ return Mage::helper('brand')->__('Manage Brand Products');
43
+ } else {
44
+ return Mage::helper('brand')->__('Manage Brand Products');
45
+ }
46
+ }
47
+ }
app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Block_Adminhtml_Brand_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/local/XT/Brand/Block/Adminhtml/Brand/Edit/Tab/Form.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Block_Adminhtml_Brand_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('brand_form', array('legend'=>Mage::helper('brand')->__('Item information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('brand')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('filename', 'file', array(
19
+ 'label' => Mage::helper('brand')->__('File'),
20
+ 'required' => false,
21
+ 'name' => 'filename',
22
+ ));
23
+
24
+ $fieldset->addField('brand_url', 'text', array(
25
+ 'label' => Mage::helper('brand')->__('Brand Url'),
26
+ 'class' => 'required-entry',
27
+ 'required' => true,
28
+ 'name' => 'brand_url',
29
+ ));
30
+
31
+ $fieldset->addField('description', 'editor', array(
32
+ 'name' => 'description',
33
+ 'label' => Mage::helper('brand')->__('Description'),
34
+ 'title' => Mage::helper('brand')->__('Description'),
35
+ 'style' => 'width:450px; height:200px;',
36
+ 'wysiwyg' => false,
37
+ 'required' => true,
38
+ ));
39
+
40
+ if ( Mage::getSingleton('adminhtml/session')->getBrandData() )
41
+ {
42
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getBrandData());
43
+ Mage::getSingleton('adminhtml/session')->setBrandData(null);
44
+ } elseif ( Mage::registry('brand_data') ) {
45
+ $form->setValues(Mage::registry('brand_data')->getData());
46
+ }
47
+ return parent::_prepareForm();
48
+ }
49
+ }
app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Tab/Grid.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class XT_Brand_Block_Adminhtml_Brand_Edit_Tab_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('upsellGrid');
8
+ $this->setUseAjax(true); // Using ajax grid is important
9
+ $this->setDefaultSort('entity_id');
10
+ $this->setDefaultFilter(array('in_products'=>1)); // By default we have added a filter for the rows, that in_products value to be 1
11
+ $this->setDefaultDir('ASC');
12
+ $this->setDefaultLimit(200);
13
+ $this->setSaveParametersInSession(false); //Dont save paramters in session or else it creates problems
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+ $storeId = Mage::getSingleton('adminhtml/session')->getData('brand_store_id');
19
+ if(empty($storeId))
20
+ {
21
+ $storeId = "1";
22
+ }
23
+ $collection = Mage::getModel('catalog/product')->getCollection()
24
+ ->addAttributeToSelect('name')
25
+ ->addAttributeToSelect('sku')
26
+ ->addAttributeToSelect('price')
27
+ ->addAttributeToSelect('status')
28
+ ->addAttributeToSelect('visibility')
29
+ //->addStoreFilter($storeId)
30
+ ->joinField('position',
31
+ 'brand/grid',
32
+ 'position',
33
+ 'product_id=entity_id',
34
+ '{{table}}.store_id ='.$storeId,
35
+ 'left')
36
+ //->addAttributeToFilter('type_id', array('eq' => 'simple'))
37
+ ->addFieldToFilter('status',Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
38
+ ->addAttributeToFilter('visibility', array('neq' => 1));
39
+ $this->setCollection($collection);
40
+
41
+ // return parent::_prepareCollection();
42
+
43
+ parent::_prepareCollection();
44
+ $this->getCollection()->addWebsiteNamesToResult();
45
+ return $this;
46
+ }
47
+
48
+ protected function _addColumnFilterToCollection($column)
49
+ {
50
+ // Set custom filter for in product flag
51
+ if ($column->getId() == 'in_products') {
52
+ $ids = $this->_getSelectedCustomers();
53
+ if (empty($ids)) {
54
+ $ids = 0;
55
+ }
56
+ if ($column->getFilter()->getValue()) {
57
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$ids));
58
+ } else {
59
+ if($productIds) {
60
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$ids));
61
+ }
62
+ }
63
+ }
64
+ else if ($this->getCollection()) {
65
+ if ($column->getId() == 'websites') {
66
+ $this->getCollection()->joinField('websites',
67
+ 'catalog/product_website',
68
+ 'website_id',
69
+ 'product_id=entity_id',
70
+ null,
71
+ 'left');
72
+ }
73
+ return parent::_addColumnFilterToCollection($column);
74
+ }
75
+ else {
76
+ parent::_addColumnFilterToCollection($column);
77
+ }
78
+ return $this;
79
+ }
80
+
81
+ protected function _prepareColumns()
82
+ {
83
+
84
+ $this->addColumn('in_products', array(
85
+ 'header_css_class' => 'a-center',
86
+ 'type' => 'checkbox',
87
+ 'name' => 'customer',
88
+ 'values' => $this->_getSelectedCustomers(),
89
+ 'align' => 'center',
90
+ 'index' => 'entity_id'
91
+ ));
92
+
93
+ $this->addColumn('id', array(
94
+ 'header' => Mage::helper('brand')->__('Product Id'),
95
+ 'sortable' => true,
96
+ 'width' => '60px',
97
+ 'index' => 'entity_id'
98
+ ));
99
+
100
+ $this->addColumn('name', array(
101
+ 'header' => Mage::helper('brand')->__('Name'),
102
+ 'index' => 'name'
103
+ ));
104
+ $this->addColumn('sku', array(
105
+ 'header' => Mage::helper('brand')->__('SKU'),
106
+ 'width' => '120px',
107
+ 'index' => 'sku'
108
+ ));
109
+
110
+ $this->addColumn('type', array(
111
+ 'header' => Mage::helper('brand')->__('Type'),
112
+ 'width' => 100,
113
+ 'index' => 'type_id',
114
+ 'type' => 'options',
115
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
116
+ ));
117
+
118
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
119
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
120
+ ->load()
121
+ ->toOptionHash();
122
+
123
+ $this->addColumn('set_name', array(
124
+ 'header' => Mage::helper('brand')->__('Attrib. Set Name'),
125
+ 'width' => 130,
126
+ 'index' => 'attribute_set_id',
127
+ 'type' => 'options',
128
+ 'options' => $sets,
129
+ ));
130
+
131
+ $this->addColumn('status', array(
132
+ 'header' => Mage::helper('brand')->__('Status'),
133
+ 'width' => 90,
134
+ 'index' => 'status',
135
+ 'type' => 'options',
136
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
137
+ ));
138
+
139
+ $this->addColumn('visibility', array(
140
+ 'header' => Mage::helper('brand')->__('Visibility'),
141
+ 'width' => 90,
142
+ 'index' => 'visibility',
143
+ 'type' => 'options',
144
+ 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
145
+ ));
146
+
147
+ $this->addColumn('price', array(
148
+ 'header' => Mage::helper('brand')->__('Price'),
149
+ 'type' => 'currency',
150
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
151
+ 'index' => 'price'
152
+ ));
153
+
154
+ if (!Mage::app()->isSingleStoreMode()) {
155
+ $this->addColumn('websites',
156
+ array(
157
+ 'header'=> Mage::helper('brand')->__('Websites'),
158
+ 'width' => '100px',
159
+ 'sortable' => false,
160
+ 'index' => 'websites',
161
+ 'type' => 'options',
162
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
163
+ ));
164
+ }
165
+
166
+ $this->addColumn('position', array(
167
+ 'header' => Mage::helper('brand')->__('Position'),
168
+ 'name' => 'position',
169
+ 'width' => 60,
170
+ 'type' => 'number',
171
+ 'validate_class' => 'validate-number',
172
+ 'index' => 'position',
173
+ 'editable' => true,
174
+ 'edit_only' => true
175
+ ));
176
+
177
+ return parent::_prepareColumns();
178
+ }
179
+
180
+ protected function _getSelectedCustomers() // Used in grid to return selected customers values.
181
+ {
182
+ $customers = array_keys($this->getSelectedCustomers());
183
+ return $customers;
184
+ }
185
+
186
+ public function getGridUrl()
187
+ {
188
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/upsellgrid', array('_current'=>true));
189
+ }
190
+ public function getSelectedCustomers()
191
+ {
192
+ // Customer Data
193
+ $storeId = Mage::getSingleton('adminhtml/session')->getData('brand_store_id');
194
+ $tm_id = $this->getRequest()->getParam('id');
195
+ if(!isset($tm_id)) {
196
+ $tm_id = 0;
197
+ }
198
+ $collection = Mage::getModel('brand/grid')->getCollection();
199
+ $collection->addFieldToFilter('store_id',$storeId);
200
+ $collection->addFieldToFilter('brand_id',$tm_id);
201
+ $custIds = array();
202
+ foreach($collection as $obj){
203
+ $custIds[$obj->getProductId()] = array('position'=>$obj->getPosition());
204
+ }
205
+ return $custIds;
206
+ }
207
+
208
+
209
+ }
app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Tab/Store.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class XT_Brand_Block_Adminhtml_Brand_Edit_Tab_Store extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setTemplate('brand/stores.phtml');
8
+ }
9
+
10
+ }
app/code/local/XT/Brand/Block/Adminhtml/Brand/Edit/Tabs.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Block_Adminhtml_Brand_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('brand_tabs');
9
+ $this->setDestElementId('edit_form');
10
+ $this->setTitle(Mage::helper('brand')->__('Item Information'));
11
+ }
12
+
13
+ protected function _beforeToHtml()
14
+ {
15
+ $this->addTab('store_section', array(
16
+ 'label' => Mage::helper('brand')->__('Select Stores'),
17
+ 'title' => Mage::helper('brand')->__('Select Stores'),
18
+ 'content' => $this->getLayout()->createBlock('brand/adminhtml_brand_edit_tab_store')->toHtml(),
19
+ ));
20
+
21
+ $this->addTab('form_section', array(
22
+ 'label' => Mage::helper('brand')->__('Brand Information'),
23
+ 'title' => Mage::helper('brand')->__('Brand Information'),
24
+ 'content' => $this->getLayout()->createBlock('brand/adminhtml_brand_edit_tab_form')->toHtml(),
25
+ ));
26
+
27
+ $this->addTab('grid_section', array(
28
+ 'label' => Mage::helper('brand')->__('Brand Products'),
29
+ 'title' => Mage::helper('brand')->__('Brand Products'),
30
+ 'url' => $this->getUrl('*/*/grid', array('_current' => true)),
31
+ 'class' => 'ajax',
32
+ ));
33
+
34
+ return parent::_beforeToHtml();
35
+ }
36
+ }
app/code/local/XT/Brand/Block/Adminhtml/Brand/Grid.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Block_Adminhtml_Brand_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('brandGrid');
9
+ $this->setDefaultSort('brand_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('brand/brand')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('brand_id', array(
24
+ 'header' => Mage::helper('brand')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'brand_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('brand')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ $this->addColumn('action',
37
+ array(
38
+ 'header' => Mage::helper('brand')->__('Action'),
39
+ 'width' => '100',
40
+ 'type' => 'action',
41
+ 'getter' => 'getId',
42
+ 'actions' => array(
43
+ array(
44
+ 'caption' => Mage::helper('brand')->__('Edit'),
45
+ 'url' => array('base'=> '*/*/edit'),
46
+ 'field' => 'id'
47
+ )
48
+ ),
49
+ 'filter' => false,
50
+ 'sortable' => false,
51
+ 'index' => 'stores',
52
+ 'is_system' => true,
53
+ ));
54
+
55
+ return parent::_prepareColumns();
56
+ }
57
+
58
+ protected function _prepareMassaction()
59
+ {
60
+ $this->setMassactionIdField('brand_id');
61
+ $this->getMassactionBlock()->setFormFieldName('brand');
62
+
63
+ $this->getMassactionBlock()->addItem('delete', array(
64
+ 'label' => Mage::helper('brand')->__('Delete'),
65
+ 'url' => $this->getUrl('*/*/massDelete'),
66
+ 'confirm' => Mage::helper('brand')->__('Are you sure?')
67
+ ));
68
+
69
+ return $this;
70
+ }
71
+
72
+ public function getRowUrl($row)
73
+ {
74
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
75
+ }
76
+
77
+ }
app/code/local/XT/Brand/Block/Brand.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class XT_Brand_Block_Brand extends Mage_Core_Block_Template
3
+ {
4
+ public function getBrandItems()
5
+ {
6
+ $_storeId = Mage::app()->getStore()->getId();
7
+ $_brandId = $this->getRequest()->getParam('id');
8
+ $collection = Mage::getModel('brand/grid')->getCollection();
9
+ $collection->addFieldToFilter('brand_id',$_brandId);
10
+ $collection->addFieldToFilter('store_id',$_storeId);
11
+ return $collection;
12
+ }
13
+
14
+ public function getBrandDetails()
15
+ {
16
+ $_brandId = $this->getRequest()->getParam('id');
17
+ $collection = Mage::getModel('brand/brand')->getCollection();
18
+ $collection->addFieldToFilter('brand_id',$_brandId);
19
+ return $collection->getData();
20
+ }
21
+
22
+ public function __construct()
23
+ {
24
+ parent::__construct();
25
+ }
26
+
27
+ public function _prepareLayout()
28
+ {
29
+
30
+ }
31
+
32
+ public function getProductCollection(){
33
+ $_storeId = Mage::app()->getStore()->getId();
34
+ $_brandId = $this->getRequest()->getParam('id');
35
+ $productCollection = Mage::getModel('brand/grid')->getCollection();
36
+ $productCollection->addFieldToFilter('brand_id',$_brandId);
37
+ $productCollection->addFieldToFilter('store_id',$_storeId);
38
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
39
+ $pager->setAvailableLimit(array(8=>8,12=>12,16=>16,20=>20,'all'=>'All'));
40
+ $pager->setCollection($productCollection);
41
+ $this->setChild('pager', $pager);
42
+
43
+ return $productCollection;
44
+ }
45
+
46
+ public function getPagerHtml(){
47
+ return $this->getChildHtml('pager');
48
+ }
49
+
50
+ public function getPriceHtml($product)
51
+ {
52
+ $this->setTemplate('catalog/product/price.phtml');
53
+ $this->setProduct($product);
54
+ return $this->toHtml();
55
+ }
56
+
57
+ public function getAddToCartUrl($product, $additional = array())
58
+ {
59
+ if ($product->getTypeInstance(true)->hasRequiredOptions($product)) {
60
+ if (!isset($additional['_escape'])) {
61
+ $additional['_escape'] = true;
62
+ }
63
+ if (!isset($additional['_query'])) {
64
+ $additional['_query'] = array();
65
+ }
66
+ $additional['_query']['options'] = 'cart';
67
+
68
+ return $this->getProductUrl($product, $additional);
69
+ }
70
+ return $this->helper('checkout/cart')->getAddUrl($product, $additional);
71
+ }
72
+
73
+ }
app/code/local/XT/Brand/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/XT/Brand/Model/Brand.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Model_Brand extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('brand/brand');
9
+ }
10
+ public function getproids()
11
+ {
12
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
13
+ $result = $connection->query("select * from grid_brand order by position");
14
+ while ($row = $result->fetch() ) {
15
+ $ids[]=$row['product_id'];
16
+ }
17
+ return $ids;
18
+ }
19
+ }
app/code/local/XT/Brand/Model/Grid.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class XT_Brand_Model_Grid extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('brand/grid');
8
+ }
9
+ }
app/code/local/XT/Brand/Model/Mysql4/Brand.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Model_Mysql4_Brand extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the manager_id refers to the key field in your database table.
8
+ $this->_init('brand/brand', 'brand_id');
9
+ }
10
+ }
app/code/local/XT/Brand/Model/Mysql4/Brand/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Model_Mysql4_Brand_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('brand/brand');
9
+ }
10
+ }
app/code/local/XT/Brand/Model/Mysql4/Grid.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Model_Mysql4_Grid extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the brand_id refers to the key field in your database table.
8
+ $this->_init('brand/grid', 'id');
9
+ }
10
+ public function addGridPosition($collection,$brand_id){
11
+ $table2 = $this->getMainTable();
12
+ $cond = $this->_getWriteAdapter()->quoteInto('e.entity_id = t2.product_id','');
13
+ $where = $this->_getWriteAdapter()->quoteInto('t2.brand_id = ? OR ', $brand_id).
14
+ $this->_getWriteAdapter()->quoteInto('isnull(t2.brand_id)','');
15
+ $collection->getSelect()->joinLeft(array('t2'=>$table2), $cond)->where($where);
16
+
17
+ //echo $collection->getSelect();die;
18
+ }
19
+ }
app/code/local/XT/Brand/Model/Mysql4/Grid/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Model_Mysql4_Grid_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('brand/grid');
9
+ }
10
+ }
app/code/local/XT/Brand/controllers/Adminhtml/BrandController.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class XT_Brand_Adminhtml_BrandController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ public function gridAction(){
7
+ $this->loadLayout();
8
+ $this->getLayout()->getBlock('customer.grid');
9
+ $this->renderLayout();
10
+ }
11
+
12
+ public function upsellgridAction(){
13
+ $this->loadLayout();
14
+ $this->getLayout()->getBlock('customer.grid');
15
+ $this->renderLayout();
16
+ }
17
+
18
+
19
+ protected function _initAction() {
20
+ $this->loadLayout()
21
+ ->_setActiveMenu('brand/items')
22
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Brand'), Mage::helper('adminhtml')->__('Item Manager'));
23
+
24
+ return $this;
25
+ }
26
+
27
+ public function indexAction() {
28
+ $this->_initAction()
29
+ ->renderLayout();
30
+ }
31
+
32
+ public function editAction() {
33
+ $id = $this->getRequest()->getParam('id');
34
+ $model = Mage::getModel('brand/brand')->load($id);
35
+
36
+ if ($model->getId() || $id == 0) {
37
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
38
+ if (!empty($data)) {
39
+ $model->setData($data);
40
+ }
41
+
42
+ Mage::register('brand_data', $model);
43
+
44
+ $this->loadLayout();
45
+ $this->_setActiveMenu('brand/items');
46
+
47
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
48
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
49
+
50
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
51
+
52
+ $this->_addContent($this->getLayout()->createBlock('brand/adminhtml_brand_edit'))
53
+ ->_addLeft($this->getLayout()->createBlock('brand/adminhtml_brand_edit_tabs'));
54
+
55
+ $this->renderLayout();
56
+ } else {
57
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('brand')->__('Item does not exist'));
58
+ $this->_redirect('*/*/edit', array('id' => 1));
59
+ }
60
+ }
61
+
62
+ public function newAction() {
63
+ $this->_forward('edit');
64
+ }
65
+
66
+ public function saveAction() {
67
+ if ($data = $this->getRequest()->getPost()) {
68
+
69
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
70
+ try {
71
+ /* Starting upload */
72
+ $uploader = new Varien_File_Uploader('filename');
73
+
74
+ // Any extention would work
75
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
76
+ $uploader->setAllowRenameFiles(false);
77
+
78
+ // Set the file upload mode
79
+ // false -> get the file directly in the specified folder
80
+ // true -> get the file in the product like folders
81
+ // (file.jpg will go in something like /media/f/i/file.jpg)
82
+ $uploader->setFilesDispersion(false);
83
+
84
+ // We set media as the upload dir
85
+ $path = Mage::getBaseDir('media') . DS . 'brand' . DS;
86
+ $uploader->save($path, $_FILES['filename']['name'] );
87
+
88
+ } catch (Exception $e) {
89
+
90
+ }
91
+
92
+ //this way the name is saved in DB
93
+ $data['filename'] = $_FILES['filename']['name'];
94
+ }
95
+
96
+ //print_r($data); die();
97
+ $_postId = $this->getRequest()->getParam('id');
98
+ $is_edit = 0;
99
+ if(isset($_postId))
100
+ {
101
+ $is_edit = 1;
102
+ $model = Mage::getModel('brand/brand')->load($_postId);
103
+ $model->setTitle($data['title']);
104
+ if(isset($data['filename'])) {
105
+ $model->setFilename($data['filename']);
106
+ }
107
+ $model->setDescription($data['description']);
108
+
109
+ //$_requestPath=mysql_real_escape_string( strtolower($data['brand_url']) );
110
+ $_requestPath = strtolower($data['brand_url']);
111
+ $_requestPath = str_replace(' ','-',$_requestPath);
112
+ $data['brand_url'] = $_requestPath;
113
+ $model->setBrandUrl($data['brand_url']);
114
+ }
115
+ else
116
+ {
117
+ $model = Mage::getModel('brand/brand');
118
+ $model->setTitle($data['title']);
119
+ if(isset($data['filename'])) {
120
+ $model->setFilename($data['filename']);
121
+ }
122
+ $model->setDescription($data['description']);
123
+
124
+ //$_requestPath=mysql_real_escape_string( strtolower($data['brand_url']) );
125
+ $_requestPath = strtolower($data['brand_url']);
126
+ $_requestPath = str_replace(' ','-',$_requestPath);
127
+ $data['brand_url'] = $_requestPath;
128
+ $model->setBrandUrl($data['brand_url']);
129
+ }
130
+
131
+ try {
132
+
133
+ $model->save();
134
+ if($is_edit == 1)
135
+ {
136
+ $urlRewriteCollection = Mage::getModel('core/url_rewrite')->getCollection()
137
+ ->addFieldToFilter('target_path',array('eq'=>'brand/index/index/id/'.$_postId))->load();
138
+ foreach ($urlRewriteCollection as $urlRewrite)
139
+ {
140
+ $urlRewrite->delete();
141
+ }
142
+ }
143
+ Mage::getModel('core/url_rewrite')->setIsSystem(0)->setStoreId(Mage::app()->getStore()->getId())
144
+ ->setOptions('')
145
+ ->setIdPath(time())
146
+ ->setTargetPath('brand/index/index/id/'.$model->getId())
147
+ ->setRequestPath('brand/'.$_requestPath)
148
+ ->save();
149
+ $brand_id = $model->getId();
150
+ if(isset($data['links'])){
151
+ $customers = Mage::helper('adminhtml/js')->decodeGridSerializedInput($data['links']['customers']); //Save the array to your database
152
+
153
+ $collection = Mage::getModel('brand/grid')->getCollection();
154
+ $collection->addFieldToFilter('brand_id',$brand_id);
155
+ $collection->addFieldToFilter('store_id',$data['store_id']);
156
+ foreach($collection as $obj){
157
+ $obj->delete();
158
+ }
159
+
160
+ foreach($customers as $key => $value){
161
+ $model2 = Mage::getModel('brand/grid');
162
+ $model2->setBrandId($brand_id);
163
+ $model2->setProductId($key);
164
+ $model2->setPosition($value['position']);
165
+ $model2->setStoreId($data['store_id']);
166
+ $model2->save();
167
+ }
168
+ }
169
+
170
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('brand')->__('Item was successfully saved'));
171
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
172
+
173
+ if ($this->getRequest()->getParam('back')) {
174
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
175
+ return;
176
+ }
177
+
178
+ $this->_redirect('*/*/');
179
+ return;
180
+ } catch (Exception $e) {
181
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
182
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
183
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
184
+ return;
185
+ }
186
+ }
187
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('brand')->__('Unable to find item to save'));
188
+ $this->_redirect('*/*/');
189
+ }
190
+
191
+ public function deleteAction() {
192
+ if( $this->getRequest()->getParam('id') > 0 ) {
193
+ try {
194
+ $model = Mage::getModel('brand/brand');
195
+
196
+ $model->setId($this->getRequest()->getParam('id'))
197
+ ->delete();
198
+
199
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
200
+ $this->_redirect('*/*/');
201
+ } catch (Exception $e) {
202
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
203
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
204
+ }
205
+ }
206
+ $this->_redirect('*/*/');
207
+ }
208
+
209
+ public function massDeleteAction() {
210
+ $brandIds = $this->getRequest()->getParam('brand');
211
+ if(!is_array($brandIds)) {
212
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
213
+ } else {
214
+ try {
215
+ foreach ($brandIds as $brandId) {
216
+ $brand = Mage::getModel('brand/brand')->load($brandId);
217
+ $brand->delete();
218
+ }
219
+ Mage::getSingleton('adminhtml/session')->addSuccess(
220
+ Mage::helper('adminhtml')->__(
221
+ 'Total of %d record(s) were successfully deleted', count($brandIds)
222
+ )
223
+ );
224
+ } catch (Exception $e) {
225
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
226
+ }
227
+ }
228
+ $this->_redirect('*/*/index');
229
+ }
230
+
231
+ public function setregisterAction() {
232
+ $store_id = $this->getRequest()->getParam('store_id');
233
+ Mage::getSingleton('adminhtml/session')->setData('brand_store_id',$store_id);
234
+ }
235
+
236
+ }
app/code/local/XT/Brand/controllers/IndexController.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class XT_Brand_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+ }
app/code/local/XT/Brand/etc/config.xml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <XT_Brand>
5
+ <version>0.1.0</version>
6
+ </XT_Brand>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <brand>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>XT_Brand</module>
14
+ <frontName>brand</frontName>
15
+ </args>
16
+ </brand>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <menu>
21
+ <catalog>
22
+ <children>
23
+ <brand module="brand">
24
+ <title>Manage Brands</title>
25
+ <sort_order>3</sort_order>
26
+ <action>brand/adminhtml_brand/</action>
27
+ </brand>
28
+ </children>
29
+ </catalog>
30
+ </menu>
31
+ <acl>
32
+ <resources>
33
+ <all>
34
+ <title>Allow Everything</title>
35
+ </all>
36
+ <admin>
37
+ <children>
38
+ <XT_Brand>
39
+ <title>Brand Module</title>
40
+ <sort_order>10</sort_order>
41
+ </XT_Brand>
42
+ </children>
43
+ </admin>
44
+ </resources>
45
+ </acl>
46
+ <layout>
47
+ <updates>
48
+ <brand>
49
+ <file>brand.xml</file>
50
+ </brand>
51
+ </updates>
52
+ </layout>
53
+ </adminhtml>
54
+ <global>
55
+ <models>
56
+ <brand>
57
+ <class>XT_Brand_Model</class>
58
+ <resourceModel>brand_mysql4</resourceModel>
59
+ </brand>
60
+ <brand_mysql4>
61
+ <class>XT_Brand_Model_Mysql4</class>
62
+ <entities>
63
+ <brand>
64
+ <table>customer_brand</table>
65
+ </brand>
66
+ <grid>
67
+ <table>grid_brand</table>
68
+ </grid>
69
+ </entities>
70
+ </brand_mysql4>
71
+ </models>
72
+ <resources>
73
+ <brand_setup>
74
+ <setup>
75
+ <module>XT_Brand</module>
76
+ </setup>
77
+ <connection>
78
+ <use>core_setup</use>
79
+ </connection>
80
+ </brand_setup>
81
+ <brand_write>
82
+ <connection>
83
+ <use>core_write</use>
84
+ </connection>
85
+ </brand_write>
86
+ <brand_read>
87
+ <connection>
88
+ <use>core_read</use>
89
+ </connection>
90
+ </brand_read>
91
+ </resources>
92
+ <blocks>
93
+ <brand>
94
+ <class>XT_Brand_Block</class>
95
+ </brand>
96
+ </blocks>
97
+ <helpers>
98
+ <brand>
99
+ <class>XT_Brand_Helper</class>
100
+ </brand>
101
+ </helpers>
102
+ </global>
103
+ <frontend>
104
+ <routers>
105
+ <brands>
106
+ <use>standard</use>
107
+ <args>
108
+ <module>XT_Brands</module>
109
+ <frontName>brands</frontName>
110
+ </args>
111
+ </brands>
112
+ </routers>
113
+ <layout>
114
+ <updates>
115
+ <brand>
116
+ <file>brand.xml</file>
117
+ </brand>
118
+ </updates>
119
+ </layout>
120
+ </frontend>
121
+ </config>
app/code/local/XT/Brand/sql/brand_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('customer_brand')};
10
+ CREATE TABLE {$this->getTable('customer_brand')} (
11
+ `brand_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `filename` varchar(255) NOT NULL default '',
14
+ `description` text NOT NULL default '',
15
+ `brand_url` varchar(255) NOT NULL default '',
16
+ PRIMARY KEY (`brand_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18
+
19
+ DROP TABLE IF EXISTS {$this->getTable('grid_brand')};
20
+ CREATE TABLE {$this->getTable('grid_brand')} (
21
+ `id` int(11) unsigned NOT NULL auto_increment,
22
+ `brand_id` int(11) NOT NULL ,
23
+ `product_id` int(11) NOT NULL ,
24
+ `position` int(11) NOT NULL default 0,
25
+ `store_id` smallint(6) NOT NULL default '1',
26
+ PRIMARY KEY (`id`)
27
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
28
+
29
+ ");
30
+
31
+ /*$installer->run("
32
+ INSERT INTO `{$installer->getTable('customer_brand')}`
33
+ (`brand_id`, `title`) values (1,'Generic Brand Products');
34
+ ");*/
35
+
36
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/brand.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <brand_adminhtml_brand_index>
4
+ <reference name="content">
5
+ <block type="brand/adminhtml_brand" name="brand" />
6
+ </reference>
7
+ </brand_adminhtml_brand_index>
8
+ <brand_adminhtml_brand_grid>
9
+ <block type="core/text_list" name="root" output="toHtml">
10
+ <block type="brand/adminhtml_brand_edit_tab_grid" name="customer.grid"/>
11
+ <block type="adminhtml/widget_grid_serializer" name="grid_serializer">
12
+ <reference name="grid_serializer">
13
+ <action method="initSerializerBlock">
14
+ <grid_block_name>customer.grid</grid_block_name>
15
+ <data_callback>getSelectedCustomers</data_callback>
16
+ <hidden_input_name>links[customers]</hidden_input_name>
17
+ <reload_param_name>customers</reload_param_name>
18
+ </action>
19
+ <action method="addColumnInputName">
20
+ <input_name>position</input_name>
21
+ </action>
22
+ </reference>
23
+ </block>
24
+ </block>
25
+ </brand_adminhtml_brand_grid>
26
+ <brand_adminhtml_brand_upsellgrid>
27
+ <block type="core/text_list" name="root" output="toHtml">
28
+ <block type="brand/adminhtml_brand_edit_tab_grid" name="customer.grid"/>
29
+ </block>
30
+ </brand_adminhtml_brand_upsellgrid>
31
+ </layout>
app/design/adminhtml/default/default/template/brand/stores.phtml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="entry-edit">
28
+ <div class="entry-edit-head">
29
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('brand')->__('Select Stores (Please choose a store view to add items)') ?></h4>
30
+ </div>
31
+ <?php $_switcherBlock = new Mage_Adminhtml_Block_Store_Switcher() ;?>
32
+ <?php if ($websites = $_switcherBlock->getWebsites()): ?>
33
+ <p class="switcher"><label for="store_switcher"><?php echo $this->__('Choose Store View') ?>:</label>
34
+ <select name="store_id" id="store_switcher" onchange="setRegister(this.value)">
35
+ <?php /*?><?php if ($_switcherBlock->hasDefaultOption()): ?>
36
+ <option value=""><?php echo $_switcherBlock->getDefaultStoreName() ?></option>
37
+ <?php endif; ?><?php */?>
38
+ <?php foreach ($websites as $website): ?>
39
+ <?php $showWebsite=false; ?>
40
+ <?php foreach ($website->getGroups() as $group): ?>
41
+ <?php $showGroup=false; ?>
42
+ <?php foreach ($_switcherBlock->getStores($group) as $store): ?>
43
+ <?php if ($showWebsite == false): ?>
44
+ <?php $showWebsite = true; ?>
45
+ <optgroup label="<?php echo $website->getName() ?>"></optgroup>
46
+ <?php endif; ?>
47
+ <?php if ($showGroup == false): ?>
48
+ <?php $showGroup = true; ?>
49
+ <optgroup label="&nbsp;&nbsp;&nbsp;<?php echo $group->getName() ?>">
50
+ <?php endif; ?>
51
+ <?php $_storeId = Mage::getSingleton('adminhtml/session')->getData('brand_store_id');
52
+ if($_storeId==""):
53
+ $_storeId = "1";
54
+ endif;
55
+ ?>
56
+ <option value="<?php echo $store->getId() ?>"<?php if($store->getId() == $_storeId): ?> selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $store->getName() ?></option>
57
+ <?php endforeach; ?>
58
+ <?php if ($showGroup): ?>
59
+ </optgroup>
60
+ <?php endif; ?>
61
+ <?php endforeach; ?>
62
+ <?php endforeach; ?>
63
+ </select>
64
+ </p>
65
+
66
+ <?php endif; ?>
67
+
68
+ <script type="text/javascript">
69
+
70
+ function setRegister(id){
71
+ new Ajax.Request('<?php echo $this->getUrl('brand/adminhtml_brand/setregister')?>',
72
+ {
73
+ method:'get',
74
+ parameters: {store_id:id},
75
+ onSuccess: function(transport){
76
+ var response = transport.responseText || "no response text";
77
+ window.location.reload();
78
+ },
79
+ onFailure: function(){ alert('Something went wrong...') }
80
+
81
+ });
82
+ }
83
+ </script>
84
+
app/design/frontend/base/default/layout/brand.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="left">
5
+ <block type="core/template" name="brandleft" before="why-buy-from-us" template="brand/brand_left.phtml"/>
6
+ </reference>
7
+ </default>
8
+ <brand_index_index>
9
+ <reference name="root">
10
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
11
+ </reference>
12
+ <reference name="left">
13
+ <remove name="left.permanent.callout"/>
14
+ <remove name="leftcms"/>
15
+ </reference>
16
+ <reference name="content">
17
+ <block type="brand/brand" name="brandproduct" template="brand/brand_products.phtml"/>
18
+ </reference>
19
+ </brand_index_index>
20
+ </layout>
app/design/frontend/base/default/template/brand/brand_left.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $collection = Mage::getModel('brand/brand')->getCollection()->getData();
2
+ if(count($collection) > 0): ?>
3
+ <div class="block"> <span class="c1"></span> <span class="c2"></span> <span class="c3"></span> <span class="c4"></span>
4
+ <div class="block-title"> <strong><span>Browse by Brand</span></strong> </div>
5
+ <ul class="side-nav">
6
+ <?php foreach($collection as $brand): ?>
7
+ <li><a href="<?php echo $this->getUrl('brand/').$brand['brand_url'] ?>"><?php echo $brand['title']; ?></a> </li>
8
+ <?php endforeach; ?>
9
+ </ul>
10
+ </div>
11
+ <?php endif; ?>
app/design/frontend/base/default/template/brand/brand_list.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $collection = Mage::getModel('brand/brand')->getCollection()->getData();//print_r($collection);
2
+ if(count($collection) > 0): ?>
3
+ <div class="block top-box"> <span class="c1"></span> <span class="c2"></span> <span class="c3"></span> <span class="c4"></span>
4
+ <div class="page-title category-title">
5
+ <h1>All Brands</h1>
6
+ </div>
7
+ </div>
8
+ <div class="s1"></div>
9
+ <div class="brand-main">
10
+ <?php foreach($collection as $brand): ?>
11
+ <div class="brand-top">
12
+ <h3><a href="<?php echo $this->getUrl('brand/').$brand['brand_url'] ?>"><?php echo $brand['title']; ?></a></h3>
13
+ <div class="brand-img"><a href="<?php echo $this->getUrl('brand/').$brand['brand_url'] ?>"><img src="<?php echo Mage::getBaseUrl('media').'brand/'.$brand['filename']?>" height="150" width="150"/></a></div>
14
+ <div class="brand-des"><?php echo substr($brand['description'],0,120).'...';?></div>
15
+ <br><button class="button" OnClick="window.location.href='<?php echo $this->getUrl('brand/').$brand['brand_url'] ?>';"><span><span>Learn More</span></span></button>
16
+
17
+ </div>
18
+ <?php endforeach; ?>
19
+ </div>
20
+ <?php endif; ?>
app/design/frontend/base/default/template/brand/brand_products.phtml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Product list template
30
+ *
31
+ * @see Mage_Catalog_Block_Product_List
32
+ */
33
+ ?>
34
+ <?php $brandContent = $this->getBrandDetails();?>
35
+ <div>
36
+ <div class="block top-box"> <span class="c1"></span> <span class="c2"></span> <span class="c3"></span> <span class="c4"></span>
37
+ <div class="page-title category-title">
38
+ <h1><?php echo $brandContent[0]['title'];?>
39
+ </h1>
40
+ </div>
41
+ </div>
42
+ <div class="s1"></div>
43
+ <div class="brand-img"><img src="<?php echo Mage::getBaseUrl('media').'brand/'.$brandContent[0]['filename']?>" height="150" width="150"/></div>
44
+
45
+
46
+ <p><?php echo $brandContent[0]['description'];?></p>
47
+ </div>
48
+
49
+ <p class="clearer"></p>
50
+ <?php
51
+ //$_productCollection=$this->getBrandItems();
52
+ $_productCollection=$this->getProductCollection();
53
+ $_helper = $this->helper('catalog/output');
54
+ ?>
55
+ <?php if(!$_productCollection->count()): ?>
56
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
57
+ <?php else: ?>
58
+ <div class="category-products">
59
+ <?php echo $this->getPagerHtml(); ?>
60
+ <?php // Grid Mode ?>
61
+ <?php $_collectionSize = $_productCollection->count() ?>
62
+ <?php //$_columnCount = $this->getColumnCount();
63
+ $_columnCount = 4;?>
64
+ <?php $i=0; foreach ($_productCollection as $_products): ?>
65
+ <?php if ($i++%$_columnCount==0): ?>
66
+ <ul class="products-grid">
67
+ <?php endif ?>
68
+ <?php $_product = Mage::getModel('catalog/product')->load($_products->getProductId()); ?>
69
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
70
+ <?php if(!$_product->isSaleable()): ?>
71
+ <div class="ost"></div>
72
+ <?php elseif($_product->getSale()):?>
73
+ <div class="sale"></div>
74
+ <?php elseif($_product->getSpecial()):?>
75
+ <div class="spl"></div>
76
+ <?php endif;?>
77
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(100); ?>" width="100" height="100" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
78
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
79
+
80
+ <?php echo $this->getPriceHtml($_product, true) ?>
81
+ <?php if($_product->getRatingSummary()): ?>
82
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
83
+ <?php endif; ?>
84
+ <div class="actions">
85
+ <?php if($_product->isSaleable()): ?>
86
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
87
+ <?php else: ?>
88
+ <p class="availability out-of-stock"><span><?php //echo $this->__('Out of stock') ?></span></p>
89
+ <?php endif; ?>
90
+ <ul class="add-to-links">
91
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
92
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist btn-link-wishlist"><?php //echo $this->__('Add to Wishlist') ?><span></span></a></li>
93
+ <?php endif; ?>
94
+ <li><a class="btn-det" href="<?php echo $_product->getProductUrl() ?>"><span></span></a></li>
95
+ </ul>
96
+ </div>
97
+ </li>
98
+ <?php unset($_product); ?>
99
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
100
+ </ul>
101
+ <?php endif ?>
102
+ <?php endforeach ?>
103
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
104
+ <div class="pager-bottom">
105
+ <?php echo $this->getPagerHtml(); ?>
106
+ </div>
107
+ </div>
108
+ <?php endif; ?>
app/etc/modules/XT_Brand.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <XT_Brand>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </XT_Brand>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Xt_Brand</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Brand Management extension to add different brand and its attributes from admin panel.&#xD;
10
+ </summary>
11
+ <description>Brand Management extension to add different brand and its attributes(like brand image, description) and assigning product to each brand from admin panel. The list of available brand will display on front-end with the provision to navigate each brand page to view individual brand details and products assigned on it.&#xD;
12
+ </description>
13
+ <notes>This extension is a stable version.</notes>
14
+ <authors><author><name>Rik Sen</name><user>pmgr</user><email>pm@hire-developer.co.uk</email></author></authors>
15
+ <date>2013-02-01</date>
16
+ <time>13:07:07</time>
17
+ <contents><target name="magelocal"><dir name="XT"><dir name="Brand"><dir name="Block"><dir name="Adminhtml"><dir name="Brand"><dir name="Edit"><file name="Form.php" hash="dcd90e8ae66db3420b7c26111e357d5e"/><dir name="Tab"><file name="Form.php" hash="d0e775ec8b8950131378570ce9473a7a"/><file name="Grid.php" hash="b0c15c18fd3651269e428c1a1ace6610"/><file name="Store.php" hash="10dc506d8809446af12cc5e12854e228"/></dir><file name="Tabs.php" hash="1a82483512d9a33e0885fd24b17673b0"/></dir><file name="Edit.php" hash="2cb9ec5994fff018f51e68a34dcea05c"/><file name="Grid.php" hash="311efc3e39483ad56e9c94dfb491ce7b"/></dir><file name="Brand.php" hash="97f897f7b7b6833b3ca506062efc2424"/></dir><file name="Brand.php" hash="eafb210a0351f9eb70407ddd00f2791e"/></dir><dir name="Helper"><file name="Data.php" hash="020f54d09424828b3ebfa10d5eed5a49"/></dir><dir name="Model"><file name="Brand.php" hash="a614da88ceaba1fbf21c94ae7c6080cc"/><file name="Grid.php" hash="1f06bfad9c5c16f29e373c1486dd1436"/><dir name="Mysql4"><dir name="Brand"><file name="Collection.php" hash="d61cb9137f782d54bff1f1675d4fcec7"/></dir><file name="Brand.php" hash="070a0d0d82aa09ee00fa8f0d12edcfe2"/><dir name="Grid"><file name="Collection.php" hash="836e7f9bd4e652a9b4bbb1f8cb924cca"/></dir><file name="Grid.php" hash="634030e8e3e0efe5546ef78cb0de232a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="BrandController.php" hash="bc8e5470e65ff61b44f64a22865e10e0"/></dir><file name="IndexController.php" hash="2551cdffa34ba8d8478c76fba9644b2e"/></dir><dir name="etc"><file name="config.xml" hash="76acb7bf62c9de063180727ec9200904"/></dir><dir name="sql"><dir name="brand_setup"><file name="mysql4-install-0.1.0.php" hash="e461607afd35da46980edffd958f571c"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="XT_Brand.xml" hash="20a1081316ec17e4533f23959db7d9dd"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="brand.xml" hash="c754bbeb5330ebf2db2cd7d5befeee52"/></dir><dir name="template"><dir name="brand"><file name="brand_left.phtml" hash="496e3a358f88f02cf74482c9ea87f164"/><file name="brand_list.phtml" hash="a009fc28e2d3280a694deb2bbf7a9e7a"/><file name="brand_products.phtml" hash="aa3023a633e3032c6689b0198242197e"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="brand.xml" hash="a950e33a108b04cba856c3c5d9f11983"/></dir><dir name="template"><dir name="brand"><file name="stores.phtml" hash="cbfe10b7765ec5ca2a18cde5d2b5bbd5"/></dir></dir></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>