Displaze_MyBrand - Version 1.7.0

Version Notes

First Stable Release

Download this release

Release Info

Developer Aftab Naveed
Extension Displaze_MyBrand
Version 1.7.0
Comparing to
See all releases


Version 1.7.0

Files changed (42) hide show
  1. app/code/community/Displaze/MyBrand/Block/Adminhtml/Image/Renderer.php +38 -0
  2. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer.php +41 -0
  3. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit.php +120 -0
  4. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Form.php +41 -0
  5. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/General.php +204 -0
  6. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/Meta.php +145 -0
  7. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/Product.php +155 -0
  8. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/Product/Grid.php +219 -0
  9. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/Product/List.php +77 -0
  10. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tabs.php +55 -0
  11. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Grid.php +107 -0
  12. app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Tab.php +46 -0
  13. app/code/community/Displaze/MyBrand/Block/Adminhtml/Widget/Grid/Column/Renderer/Checkbox.php +35 -0
  14. app/code/community/Displaze/MyBrand/Block/Manufacturer.php +61 -0
  15. app/code/community/Displaze/MyBrand/Block/Manufacturer/Link.php +49 -0
  16. app/code/community/Displaze/MyBrand/Block/Manufacturer/Product/List.php +61 -0
  17. app/code/community/Displaze/MyBrand/Block/Page/Html/Topmenu.php +65 -0
  18. app/code/community/Displaze/MyBrand/Controller/Router.php +95 -0
  19. app/code/community/Displaze/MyBrand/Helper/Data.php +36 -0
  20. app/code/community/Displaze/MyBrand/Helper/Manufacturer.php +46 -0
  21. app/code/community/Displaze/MyBrand/Model/Manufacturer.php +150 -0
  22. app/code/community/Displaze/MyBrand/Model/Manufacturer/Product.php +39 -0
  23. app/code/community/Displaze/MyBrand/Model/Observer/Product.php +84 -0
  24. app/code/community/Displaze/MyBrand/Model/Resource/Manufacturer.php +355 -0
  25. app/code/community/Displaze/MyBrand/Model/Resource/Manufacturer/Collection.php +44 -0
  26. app/code/community/Displaze/MyBrand/Model/Resource/Manufacturer/Product.php +58 -0
  27. app/code/community/Displaze/MyBrand/controllers/Adminhtml/ManufacturerController.php +232 -0
  28. app/code/community/Displaze/MyBrand/controllers/ManufacturerController.php +46 -0
  29. app/code/community/Displaze/MyBrand/etc/adminhtml.xml +41 -0
  30. app/code/community/Displaze/MyBrand/etc/config.xml +167 -0
  31. app/code/community/Displaze/MyBrand/sql/mybrand_setup/install-1.7.0.php +149 -0
  32. app/design/adminhtml/default/default/layout/displaze/mybrand.xml +59 -0
  33. app/design/adminhtml/default/default/template/displaze/mybrand/manufacturer/edit/tab/product.phtml +247 -0
  34. app/design/adminhtml/default/default/template/displaze/mybrand/manufacturer/edit/tab/product/grid.phtml +24 -0
  35. app/design/adminhtml/default/default/template/displaze/mybrand/manufacturer/edit/tab/product/list.phtml +238 -0
  36. app/design/adminhtml/default/default/template/displaze/mybrand/manufacturer/tab.phtml +71 -0
  37. app/design/frontend/default/default/layout/displaze/mybrand.xml +35 -0
  38. app/design/frontend/default/default/template/displaze/mybrand/manufacturer/link.phtml +39 -0
  39. app/design/frontend/default/default/template/displaze/mybrand/manufacturer/view.phtml +40 -0
  40. app/design/frontend/default/default/template/displaze/mybrand/page/html/topmenu.phtml +54 -0
  41. app/etc/modules/Displaze_MyBrand.xml +33 -0
  42. package.xml +18 -0
app/code/community/Displaze/MyBrand/Block/Adminhtml/Image/Renderer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Renderer.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Adminhtml_Image_Renderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
25
+ {
26
+ public function render(Varien_Object $row)
27
+ {
28
+ if($row->getData($this->getColumn()->getIndex())) {
29
+ $path = Mage::helper('mybrand')->getBrandMediaPath().$row->getData($this->getColumn()->getIndex());
30
+ if(file_exists($path)) {
31
+ $src = Mage::helper('mybrand')->getBrandMediaUrl().$row->getData($this->getColumn()->getIndex());
32
+ return "<img src={$src} width='100' height='100' />";
33
+ }
34
+ }
35
+
36
+ return '(none)';
37
+ }
38
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Manufacturer.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ /**
25
+ * Container for Grid.
26
+ *
27
+ * @package Displaze_MyBrand
28
+ * @subpackage Manufacturer
29
+ */
30
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer extends Mage_Adminhtml_Block_Widget_Grid_Container
31
+ {
32
+ public function __construct()
33
+ {
34
+ $this->setId('mybrand_manufacturer_gridbox');
35
+ $this->_controller = 'adminhtml_manufacturer';
36
+ $this->_blockGroup = 'mybrand';
37
+ $this->_headerText = 'Manufacturer Management';
38
+ $this->_addButtonLabel = 'Add Manufacturer';
39
+ parent::__construct();
40
+ }
41
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Edit.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
25
+ {
26
+
27
+ public function __construct()
28
+ {
29
+ $this->_objectId = 'id';
30
+ $this->_blockGroup = 'mybrand';
31
+ $this->_controller = 'adminhtml_manufacturer';
32
+
33
+ parent::__construct();
34
+
35
+ if ($this->_isAllowedAction('save')) {
36
+ $this->_updateButton('save', 'label', Mage::helper('mybrand')->__('Save Manufacturer'));
37
+ $this->_addButton('saveandcontinue', array(
38
+ 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
39
+ 'onclick' => 'saveAndContinueEdit(\''.$this->_getSaveAndContinueUrl().'\')',
40
+ 'class' => 'save',
41
+ ), -100);
42
+ } else {
43
+ $this->_removeButton('save');
44
+ }
45
+
46
+ if ($this->_isAllowedAction('delete')) {
47
+ $this->_updateButton('delete', 'label', Mage::helper('mybrand')->__('Delete Manufacturer'));
48
+ } else {
49
+ $this->_removeButton('delete');
50
+ }
51
+
52
+
53
+ }
54
+
55
+ public function getHeaderText()
56
+ {
57
+ if( Mage::registry('manufacturer_data') && Mage::registry('manufacturer_data')->getId() ) {
58
+ return Mage::helper('mybrand')->__("Edit Manufacturer '%s'", $this->htmlEscape(Mage::registry('manufacturer_data')->getTitle()));
59
+ } else {
60
+ return Mage::helper('mybrand')->__('Add New Manufacturer');
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Check permission for passed action
66
+ *
67
+ * @param string $action
68
+ * @return bool
69
+ */
70
+ protected function _isAllowedAction($action)
71
+ {
72
+ //return Mage::getSingleton('admin/session')->isAllowed('mylink/link/' . $action);
73
+ return true;
74
+ }
75
+
76
+ /**
77
+ * Getter of url for "Save and Continue" button
78
+ * tab_id will be replaced by desired by JS later
79
+ *
80
+ * @return string
81
+ */
82
+ protected function _getSaveAndContinueUrl()
83
+ {
84
+ return $this->getUrl('*/*/save', array(
85
+ '_current' => true,
86
+ 'back' => 'edit',
87
+ 'active_tab' => '{{tab_id}}'
88
+ ));
89
+ }
90
+
91
+ /**
92
+ * prepare Save And Continue Edit js renedering.
93
+ * @return type
94
+ */
95
+ protected function _prepareLayout()
96
+ {
97
+ $tabsBlock = $this->getLayout()->getBlock('mybrand_adminhtml_manufacturer_edit_tabs');
98
+ if ($tabsBlock) {
99
+ $tabsBlockJsObject = $tabsBlock->getJsObjectName();
100
+ $tabsBlockPrefix = $tabsBlock->getId() . '_';
101
+ } else {
102
+ $tabsBlockJsObject = 'mybrand_tabsJsTabs';
103
+ $tabsBlockPrefix = 'mybrand_tabs_';
104
+ }
105
+
106
+ $this->_formScripts[] = "
107
+ function saveAndContinueEdit(urlTemplate) {
108
+ var tabsIdValue = " . $tabsBlockJsObject . ".activeTab.id;
109
+ var tabsBlockPrefix = '" . $tabsBlockPrefix . "';
110
+ if (tabsIdValue.startsWith(tabsBlockPrefix)) {
111
+ tabsIdValue = tabsIdValue.substr(tabsBlockPrefix.length)
112
+ }
113
+ var template = new Template(urlTemplate, /(^|.|\\r|\\n)({{(\w+)}})/);
114
+ var url = template.evaluate({tab_id:tabsIdValue});
115
+ editForm.submit(url);
116
+ }
117
+ ";
118
+ return parent::_prepareLayout();
119
+ }
120
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Form.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Form.php
4
+ *
5
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+ *
7
+ * This file is part of Displaze Web Services Inc..
8
+ *
9
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ */
22
+
23
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
24
+ {
25
+
26
+ protected function _prepareForm()
27
+ {
28
+ $form = new Varien_Data_Form(array(
29
+ 'id' => 'edit_form',
30
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
31
+ 'method' => 'post',
32
+ 'enctype' => 'multipart/form-data'
33
+ ));
34
+
35
+ $form->setUseContainer(true);
36
+ $this->setForm($form);
37
+
38
+ return parent::_prepareForm();
39
+ }
40
+
41
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/General.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * General.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Edit_Tab_General extends Mage_Adminhtml_Block_Widget_Form
25
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
26
+ {
27
+
28
+ protected function _prepareForm()
29
+ {
30
+ /* @var $model Displaze_MySlideshow_Slideshow */
31
+ $model = Mage::registry('mybrand_manufacturer');
32
+
33
+ /*
34
+ * Checking if user have permissions to save information
35
+ */
36
+ if ($this->_isAllowedAction('save')) {
37
+ $isElementDisabled = false;
38
+ } else {
39
+ $isElementDisabled = true;
40
+ }
41
+
42
+ $form = new Varien_Data_Form();
43
+
44
+ $form->setHtmlIdPrefix('mybrand_manufacturer_');
45
+
46
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('mybrand')->__('Manufacturer')));
47
+ if($model) {
48
+ if ($model->getId()) {
49
+ $fieldset->addField('id', 'hidden', array(
50
+ 'name' => 'id',
51
+ ));
52
+ }
53
+ }
54
+
55
+
56
+ $fieldset->addField('title', 'text', array(
57
+ 'name' => 'title',
58
+ 'label' => Mage::helper('mybrand')->__('Title'),
59
+ 'title' => Mage::helper('mybrand')->__('Title'),
60
+ 'required' => true,
61
+ 'disabled' => $isElementDisabled
62
+ ));
63
+
64
+ $fieldset->addField('identifier', 'text', array(
65
+ 'name' => 'identifier',
66
+ 'label' => Mage::helper('mybrand')->__('Url Key'),
67
+ 'title' => Mage::helper('mybrand')->__('Url Key'),
68
+ 'required' => true,
69
+ 'disabled' => $isElementDisabled
70
+ ));
71
+
72
+
73
+ $fieldset->addField('logo', 'file', array(
74
+ 'label' => Mage::helper('mybrand')->__('Logo Image'),
75
+ 'required' => false,
76
+ 'name' => 'logo',
77
+ 'after_element_html' => $this->_getImage() != false ? $this->_getImage() : ''
78
+ ));
79
+
80
+ $fieldset->addField('content', 'editor', array(
81
+ 'name' => 'content',
82
+ 'label' => Mage::helper('mybrand')->__('Content'),
83
+ 'title' => Mage::helper('mybrand')->__('Content'),
84
+ 'required' => true,
85
+ 'disabled' => $isElementDisabled
86
+ ));
87
+
88
+
89
+ /**
90
+ * Check is single store mode
91
+ */
92
+ if (!Mage::app()->isSingleStoreMode()) {
93
+ $fieldset->addField('store_id', 'multiselect', array(
94
+ 'name' => 'stores[]',
95
+ 'label' => Mage::helper('mybrand')->__('Store View'),
96
+ 'title' => Mage::helper('mybrand')->__('Store View'),
97
+ 'required' => true,
98
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
99
+ 'disabled' => $isElementDisabled
100
+ ));
101
+ }
102
+ else {
103
+ $fieldset->addField('store_id', 'hidden', array(
104
+ 'name' => 'stores[]',
105
+ 'value' => Mage::app()->getStore(true)->getId()
106
+ ));
107
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
108
+ }
109
+
110
+ $fieldset->addField('status', 'select', array(
111
+ 'label' => Mage::helper('mybrand')->__('Status'),
112
+ 'title' => Mage::helper('mybrand')->__('Status'),
113
+ 'name' => 'status',
114
+ 'required' => true,
115
+ 'options' => array(
116
+ '1' => Mage::helper('mybrand')->__('Enabled'),
117
+ '0' => Mage::helper('mybrand')->__('Disabled'),
118
+ ),
119
+ 'disabled' => $isElementDisabled
120
+ ));
121
+
122
+ if (!$model->getId()) {
123
+ $model->setData('status', $isElementDisabled ? '0' : '1');
124
+ }
125
+
126
+ // Mage::dispatchEvent('renegade_mylink_link_edit_tab_main_prepare_form', array('form' => $form));
127
+
128
+ $form->setValues($model->getData());
129
+ $this->setForm($form);
130
+
131
+ return parent::_prepareForm();
132
+ }
133
+
134
+ /**
135
+ * return image url if it exists
136
+ * @return boolean
137
+ */
138
+ protected function _getImage()
139
+ {
140
+ $id = $this->getRequest()->getParam('id');
141
+ if($id) {
142
+ $manufacturer = Mage::getModel('mybrand/manufacturer')->load($id);
143
+ $image = Mage::helper('mybrand')->getBrandMediaUrl() . $manufacturer->getLogo();
144
+ //return "<img src={$image} width='22' height='22' /><br /><input type='checkbox' id='delete-image' name='delete_image' /><label for='delete-image'> Delete Image</label>";
145
+ return "<img src={$image} width='22' height='22' />";
146
+ }
147
+
148
+ return false;
149
+ }
150
+
151
+ /**
152
+ * Prepare label for tab
153
+ *
154
+ * @return string
155
+ */
156
+ public function getTabLabel()
157
+ {
158
+ return Mage::helper('mybrand')->__('General');
159
+ }
160
+
161
+ /**
162
+ * Prepare title for tab
163
+ *
164
+ * @return string
165
+ */
166
+ public function getTabTitle()
167
+ {
168
+ return Mage::helper('mybrand')->__('General');
169
+ }
170
+
171
+ /**
172
+ * Returns status flag about this tab can be shown or not
173
+ *
174
+ * @return true
175
+ */
176
+ public function canShowTab()
177
+ {
178
+ return true;
179
+ }
180
+
181
+ /**
182
+ * Returns status flag about this tab hidden or not
183
+ *
184
+ * @return true
185
+ */
186
+ public function isHidden()
187
+ {
188
+ return false;
189
+ }
190
+
191
+ /**
192
+ * Check permission for passed action
193
+ *
194
+ * @param string $action
195
+ * @return bool
196
+ */
197
+ protected function _isAllowedAction($action)
198
+ {
199
+ //return Mage::getSingleton('admin/session')->isAllowed('mylink/link/' . $action);
200
+ return true;
201
+ }
202
+
203
+
204
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/Meta.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Meta.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Edit_Tab_Meta extends Mage_Adminhtml_Block_Widget_Form
25
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
26
+ {
27
+
28
+ protected function _prepareForm()
29
+ {
30
+ /* @var $model Displaze_MyBrand_Brand */
31
+ $model = Mage::registry('mybrand_manufacturer');
32
+
33
+ /*
34
+ * Checking if user have permissions to save information
35
+ */
36
+ if ($this->_isAllowedAction('save')) {
37
+ $isElementDisabled = false;
38
+ } else {
39
+ $isElementDisabled = true;
40
+ }
41
+
42
+ $form = new Varien_Data_Form();
43
+
44
+ $form->setHtmlIdPrefix('mybrand_manufacturer_');
45
+
46
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('mybrand')->__('Manufacturer')));
47
+ if($model) {
48
+ if ($model->getId()) {
49
+ $fieldset->addField('id', 'hidden', array(
50
+ 'name' => 'id',
51
+ ));
52
+ }
53
+ }
54
+
55
+
56
+ $fieldset->addField('meta_title', 'text', array(
57
+ 'name' => 'meta_title',
58
+ 'label' => Mage::helper('mybrand')->__('Meta Title'),
59
+ 'title' => Mage::helper('mybrand')->__('Meta Title'),
60
+ 'required' => false,
61
+ 'disabled' => $isElementDisabled
62
+ ));
63
+
64
+ $fieldset->addField('meta_keyword', 'text', array(
65
+ 'name' => 'meta_keyword',
66
+ 'label' => Mage::helper('mybrand')->__('Meta Keywords'),
67
+ 'title' => Mage::helper('mybrand')->__('Meta Keywords'),
68
+ 'required' => false,
69
+ 'disabled' => $isElementDisabled
70
+ ));
71
+
72
+ $fieldset->addField('meta_description', 'textarea', array(
73
+ 'name' => 'meta_description',
74
+ 'label' => Mage::helper('mybrand')->__('Meta Description'),
75
+ 'title' => Mage::helper('mybrand')->__('Meta Description'),
76
+ 'required' => false,
77
+ 'disabled' => $isElementDisabled
78
+ ));
79
+
80
+
81
+
82
+
83
+ // Mage::dispatchEvent('renegade_mylink_link_edit_tab_main_prepare_form', array('form' => $form));
84
+
85
+ $form->setValues($model->getData());
86
+ $this->setForm($form);
87
+
88
+ return parent::_prepareForm();
89
+ }
90
+
91
+
92
+ /**
93
+ * Prepare label for tab
94
+ *
95
+ * @return string
96
+ */
97
+ public function getTabLabel()
98
+ {
99
+ return Mage::helper('mybrand')->__('Meta Information');
100
+ }
101
+
102
+ /**
103
+ * Prepare title for tab
104
+ *
105
+ * @return string
106
+ */
107
+ public function getTabTitle()
108
+ {
109
+ return Mage::helper('mybrand')->__('Meta Information');
110
+ }
111
+
112
+ /**
113
+ * Returns status flag about this tab can be shown or not
114
+ *
115
+ * @return true
116
+ */
117
+ public function canShowTab()
118
+ {
119
+ return true;
120
+ }
121
+
122
+ /**
123
+ * Returns status flag about this tab hidden or not
124
+ *
125
+ * @return true
126
+ */
127
+ public function isHidden()
128
+ {
129
+ return false;
130
+ }
131
+
132
+ /**
133
+ * Check permission for passed action
134
+ *
135
+ * @param string $action
136
+ * @return bool
137
+ */
138
+ protected function _isAllowedAction($action)
139
+ {
140
+ //return Mage::getSingleton('admin/session')->isAllowed('mylink/link/' . $action);
141
+ return true;
142
+ }
143
+
144
+
145
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/Product.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Product.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+
25
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Edit_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid_Container
26
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
27
+ {
28
+
29
+ public function __construct()
30
+ {
31
+ $this->_controller = 'adminhtml_manufacturer_edit_tab_product';
32
+ $this->_blockGroup = 'mybrand';
33
+ parent::__construct();
34
+ }
35
+
36
+ /**
37
+ * Get HTML code for button View Available Products
38
+ *
39
+ * @return string
40
+ */
41
+ public function getAddButtonHtml()
42
+ {
43
+ $addButtonData = array(
44
+ 'id' => 'product_add_button',
45
+ 'label' => $this->__('Add Product(s)'),
46
+ //'on_click' => 'product.showGridBox(event)',
47
+ 'class' => 'add',
48
+ );
49
+ return $this->getLayout()
50
+ ->createBlock('adminhtml/widget_button')
51
+ ->setData($addButtonData)
52
+ ->toHtml();
53
+ }
54
+
55
+ public function getAddSelectedProductButtonHtml()
56
+ {
57
+ $addButtonData = array(
58
+ 'id' => 'add_button_product',
59
+ 'label' => $this->__('Add Selected Products(s) to Manufacturer'),
60
+ 'onclick' => 'brandProduct.productGridAddSelected(event)',
61
+ 'class' => 'add',
62
+ );
63
+ return $this->getLayout()
64
+ ->createBlock('adminhtml/widget_button')
65
+ ->setData($addButtonData)
66
+ ->toHtml();
67
+ }
68
+
69
+ public function getDeleteButtonHtml()
70
+ {
71
+ $deleteButtonData = array(
72
+ 'id' => 'delete_product_button',
73
+ 'label' => $this->__('Delete Product'),
74
+ 'onclick' => 'brandProduct.remove(this)',
75
+ 'class' => 'delete icon-btn',
76
+ );
77
+ return $this->getLayout()
78
+ ->createBlock('adminhtml/widget_button')
79
+ ->setData($deleteButtonData)
80
+ ->toHtml();
81
+ }
82
+
83
+
84
+ public function getHeaderText()
85
+ {
86
+ return $this->__('Please Select Products to Add to Manufacturer');
87
+ }
88
+
89
+ public function getProductGridContainerUrl()
90
+ {
91
+ return $this->getUrl('*/*/grid', array('_current'=>true));
92
+ }
93
+
94
+ public function getManufacturerProductCollection()
95
+ {
96
+ return $productCollection = Mage::getModel('catalog/product')->getCollection()
97
+ ->addAttributeToSelect('*')
98
+ ->addAttributeToFilter('entity_id', array('IN'=> $this->_getManufacturerProductIds()));
99
+
100
+ }
101
+
102
+ protected function _getManufacturerProductIds()
103
+ {
104
+ $manufacturer = Mage::registry('current_manufacturer');
105
+ if($manufacturer == null) {
106
+ $id = Mage::app()->getRequest()->getParam('id');
107
+ $manufacturer = Mage::getModel('mybrand/manufacturer')->load($id);
108
+ }
109
+
110
+ $productIds = array(0);
111
+ $productIds = $manufacturer->getProductIds();
112
+
113
+ return $productIds;
114
+ }
115
+
116
+ /**
117
+ * Prepare label for tab
118
+ *
119
+ * @return string
120
+ */
121
+ public function getTabLabel()
122
+ {
123
+ return Mage::helper('mybrand')->__('Products');
124
+ }
125
+
126
+ /**
127
+ * Prepare title for tab
128
+ *
129
+ * @return string
130
+ */
131
+ public function getTabTitle()
132
+ {
133
+ return Mage::helper('mybrand')->__('Products');
134
+ }
135
+
136
+ /**
137
+ * Returns status flag about this tab can be shown or not
138
+ *
139
+ * @return true
140
+ */
141
+ public function canShowTab()
142
+ {
143
+ return true;
144
+ }
145
+
146
+ /**
147
+ * Returns status flag about this tab hidden or not
148
+ *
149
+ * @return true
150
+ */
151
+ public function isHidden()
152
+ {
153
+ return false;
154
+ }
155
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/Product/Grid.php ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Renegade Group
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 Renegade
22
+ * @copyright Copyright (c) 2008-2011 Renegade Group (http://www.renegadefurniture.com)
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ */
25
+ /**
26
+ * Products Grid to add to Google Content
27
+ *
28
+ * @category Mage
29
+ * @package Mage_GoogleShopping
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Edit_Tab_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
33
+ {
34
+
35
+ protected $_showRss = false;
36
+ protected $_showActionColumn = false;
37
+ protected $_showCategories = false;
38
+
39
+ protected $_showExportType = false;
40
+
41
+ /**
42
+ * Massaction block name
43
+ *
44
+ * @var string
45
+ */
46
+ // protected $_massactionBlockName = 'mybrand/adminhtml_widget_grid_massaction';
47
+
48
+
49
+ public function __construct()
50
+ {
51
+ parent::__construct();
52
+ $this->setId('mybrandproduct_selection_search_grid');
53
+ $this->setDefaultSort('id');
54
+ $this->setUseAjax(true);
55
+
56
+
57
+ }
58
+
59
+ protected function _prepareCollection()
60
+ {
61
+ /*$collection = parent::_prepareCollection();
62
+ $collection->addAttributeToFilter('entity_id', array('nin' => $this->_getManufacturerProductIds()));*/
63
+
64
+ parent::_prepareCollection();
65
+ }
66
+
67
+ protected function _prepareColumns()
68
+ {
69
+ $this->addColumn('product_add_checkbox', array(
70
+ 'id' => 'product_add_checkbox',
71
+ 'header_css_class' => 'a-center',
72
+ 'align' => 'center',
73
+ 'type' => 'checkbox',
74
+ 'field_name'=> '',
75
+ 'filter' => false,
76
+ 'sortable' => false,
77
+ 'index' => 'product_id',
78
+ 'renderer' => 'mybrand/adminhtml_widget_grid_column_renderer_checkbox'
79
+ ));
80
+
81
+
82
+
83
+ $this->addColumn('name', array(
84
+ 'header' => Mage::helper('sales')->__('Product Name'),
85
+ 'index' => 'name',
86
+ 'column_css_class' => 'product_name'
87
+ ));
88
+
89
+ $this->addColumn('type',
90
+ array(
91
+ 'header'=> Mage::helper('catalog')->__('Type'),
92
+ 'width' => '60px',
93
+ 'index' => 'type_id',
94
+ 'type' => 'options',
95
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
96
+ 'column_css_class' => 'product_type'
97
+ ));
98
+
99
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
100
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
101
+ ->load()
102
+ ->toOptionHash();
103
+
104
+ $this->addColumn('set_name',
105
+ array(
106
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
107
+ 'width' => '100px',
108
+ 'index' => 'attribute_set_id',
109
+ 'type' => 'options',
110
+ 'options' => $sets,
111
+ ));
112
+
113
+ $this->addColumn('sku', array(
114
+ 'header' => Mage::helper('sales')->__('SKU'),
115
+ 'width' => '80px',
116
+ 'index' => 'sku',
117
+ 'column_css_class'=> 'product_sku'
118
+ ));
119
+
120
+ $this->addColumn('price', array(
121
+ 'header' => Mage::helper('sales')->__('Price'),
122
+ 'align' => 'center',
123
+ 'type' => 'currency',
124
+ 'currency_code' => $this->_getStore()->getDefaultCurrencyCode(),
125
+ 'rate' => $this->_getStore()->getBaseCurrency()->getRate($this->_getStore()->getDefaultCurrencyCode()),
126
+ 'index' => 'price',
127
+ 'column_css_class' => 'product_price'
128
+ ));
129
+
130
+ if (!Mage::app()->isSingleStoreMode()) {
131
+ $this->addColumn('websites',
132
+ array(
133
+ 'header'=> Mage::helper('catalog')->__('Websites'),
134
+ 'width' => '100px',
135
+ 'sortable' => false,
136
+ 'index' => 'websites',
137
+ 'type' => 'options',
138
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
139
+ ));
140
+ }
141
+
142
+ $this->addColumn('product_status',
143
+ array(
144
+ 'header'=> Mage::helper('catalog')->__('Status'),
145
+ 'width' => '70px',
146
+ 'index' => 'status',
147
+ 'type' => 'options',
148
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
149
+ ));
150
+
151
+
152
+ }
153
+
154
+ /**
155
+ * define custom widget renderer here.
156
+ */
157
+ /*public function getColumnRenderers()
158
+ {
159
+ return array('massaction' => 'adminhtml/widget_grid_column_renderer_massaction');
160
+ }*/
161
+
162
+ /**
163
+ * Grid url getter
164
+ *
165
+ * @return string current grid url
166
+ */
167
+ public function getGridUrl()
168
+ {
169
+ return $this->getUrl('*/manufacturer/grid', array('index' => $this->getIndex(),'_current'=>true));
170
+ }
171
+
172
+ /**
173
+ * Get array with product ids, which was added to Manufacturer
174
+ *
175
+ * @return array
176
+ */
177
+ protected function _getManufacturerProductIds()
178
+ {
179
+ $manufacturer = Mage::registry('current_manufacturer');
180
+ if($manufacturer == null) {
181
+ $id = Mage::app()->getRequest()->getParam('id');
182
+ $manufacturer = Mage::getModel('mybrand/manufacturer')->load($id);
183
+ }
184
+
185
+ $productIds = array(0);
186
+ $productIds = $manufacturer->getProductIds();
187
+
188
+ return $productIds;
189
+ }
190
+
191
+ /**
192
+ * Checkbox Check JS Callback
193
+ *
194
+ * @return string
195
+ */
196
+ public function getCheckboxCheckCallback()
197
+ {
198
+ return "function (grid, event) {
199
+ brandProduct.productGridCheckboxCheck(event);
200
+ }";
201
+
202
+ }
203
+
204
+
205
+ protected function _prepareMassaction()
206
+ {
207
+ return $this;
208
+ }
209
+
210
+ /**
211
+ * Get store model by request param
212
+ *
213
+ * @return Mage_Core_Model_Store
214
+ */
215
+ protected function _getStore()
216
+ {
217
+ return Mage::app()->getStore($this->getRequest()->getParam('store'));
218
+ }
219
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tab/Product/List.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Renegade Group
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 Renegade
22
+ * @copyright Copyright (c) 2008-2011 Renegade Group (http://www.renegadefurniture.com)
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ */
25
+
26
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Edit_Tab_Product_List extends Mage_Adminhtml_Block_Widget
27
+ {
28
+
29
+ public function __construct() {
30
+ parent::__construct();
31
+ $this->setSkipGenerateContent(true);
32
+ // $this->setTemplate('displaze/mybrand/manufacturer/edit/tabs/product/list.phtml');
33
+ }
34
+
35
+
36
+ public function getFamilyProducts() {
37
+ /* $myproductfamilyModel=Mage::registry("myproductfamily_data");
38
+ $familyId = $myproductfamilyModel->getId();
39
+
40
+ if( isset($familyId) && $familyId > 0 )
41
+ {
42
+ $collection = Mage::getModel('catalog/product')->getCollection();
43
+ $collection->addAttributeToSelect(array('name', 'url_key', 'type_id'));
44
+ $collection->getSelect()->join(
45
+ array('fp'=>'my_product_family_content'),
46
+ 'e.entity_id = fp.product_entity_id')
47
+ ->where('fp.myproductfamily_id=' . $familyId);
48
+
49
+ $collection->load();
50
+ return $collection;
51
+ }
52
+ else
53
+ {
54
+ return false;
55
+ }*/
56
+ }
57
+
58
+ public function getProductDeleteButtonHtml()
59
+ {
60
+ return $this->getChildHtml('delete_product_button');
61
+ }
62
+ public function getProductAddButtonHtml()
63
+ {
64
+ return $this->getChildHtml('add_product_button');
65
+ }
66
+
67
+ public function getProductGridBoxUrl()
68
+ {
69
+ return $this->getUrl('*/*/gridbox', array('_current'=>true));
70
+ }
71
+ public function getProductGridContainerUrl()
72
+ {
73
+ return $this->getUrl('*/*/gridcontainer', array('_current'=>true));
74
+ }
75
+
76
+
77
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Edit/Tabs.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Tabs.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+
25
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
26
+ {
27
+ public function __construct()
28
+ {
29
+ parent::__construct();
30
+ $this->setId('mybrand_tabs');
31
+ $this->setDestElementId('edit_form');
32
+ $this->setTitle(Mage::helper('mybrand')->__('Manufacturer Information'));
33
+ }
34
+
35
+ /**
36
+ * if you would want to create the tabs using code uncomment the following, else
37
+ * it has to be created using xml file which is the proper and neat method of doing it
38
+
39
+ protected function _beforeToHtml()
40
+ {
41
+ $this->addTab('main_section', array(
42
+ 'label' => Mage::helper('mylink')->__('Link Information'),
43
+ 'title' => Mage::helper('mylink')->__('Link Information'),
44
+ 'content' => $this->getLayout()->createBlock('mylink/adminhtml_link_edit_tab_main')->toHtml(),
45
+ ));
46
+
47
+ $this->addTab('meta_section', array(
48
+ 'label' => Mage::helper('mylink')->__('Meta Data'),
49
+ 'title' => Mage::helper('mylink')->__('Meta Data'),
50
+ 'content' => $this->getLayout()->createBlock('mylink/adminhtml_link_edit_tab_meta')->toHtml(),
51
+ ));
52
+
53
+ parent::_beforeToHtml();
54
+ }*/
55
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Grid.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Grid.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Grid extends Mage_Adminhtml_Block_Widget_Grid
25
+ {
26
+ public function __construct()
27
+ {
28
+ parent::__construct();
29
+ $this->setId('displaze_manufacturer_grid');
30
+ $this->setDefaultSort('id');
31
+ $this->setDefaultDir('ASC');
32
+ }
33
+
34
+ protected function _prepareCollection()
35
+ {
36
+ $collection = Mage::getModel('mybrand/manufacturer')->getCollection();
37
+
38
+ $this->setCollection($collection);
39
+
40
+ return parent::_prepareCollection();
41
+ }
42
+
43
+ protected function _prepareColumns()
44
+ {
45
+
46
+ $this->addColumn('id', array(
47
+ 'header' => Mage::helper('mybrand')->__('ID'),
48
+ 'align' => 'left',
49
+ 'width' => '10px',
50
+ 'index' => 'id',
51
+ ));
52
+
53
+ $this->addColumn('logo', array(
54
+ 'header' => Mage::helper('mybrand')->__('Logo'),
55
+ 'align' => 'center',
56
+ 'index' => 'logo',
57
+ 'width' => '100px',
58
+ 'renderer' => 'mybrand/adminhtml_image_renderer'
59
+ ));
60
+
61
+ $this->addColumn('title', array(
62
+ 'header' => Mage::helper('mybrand')->__('Title'),
63
+ 'align' => 'left',
64
+ 'index' => 'title',
65
+ ));
66
+
67
+ $this->addColumn('identifier', array(
68
+ 'header' => Mage::helper('mybrand')->__('Url Key'),
69
+ 'align' => 'left',
70
+ 'index' => 'identifier',
71
+ ));
72
+
73
+ $this->addColumn('status', array(
74
+ 'header' => Mage::helper('mybrand')->__('Status'),
75
+ 'index' => 'status',
76
+ 'type' => 'options',
77
+ 'options' => Mage::getSingleton('mybrand/manufacturer')->getAvailableStatuses()
78
+ ));
79
+
80
+ $this->addColumn('creation_time', array(
81
+ 'header' => Mage::helper('mybrand')->__('Date Created'),
82
+ 'index' => 'creation_time',
83
+ 'type' => 'datetime',
84
+ ));
85
+
86
+ $this->addColumn('update_time', array(
87
+ 'header' => Mage::helper('mybrand')->__('Last Modified'),
88
+ 'index' => 'update_time',
89
+ 'type' => 'datetime',
90
+ ));
91
+
92
+
93
+
94
+ return parent::_prepareColumns();
95
+ }
96
+
97
+ /**
98
+ * Row click url
99
+ *
100
+ * @return string
101
+ */
102
+ public function getRowUrl($row)
103
+ {
104
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
105
+ }
106
+
107
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Manufacturer/Tab.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Tab.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Adminhtml_Manufacturer_Tab extends Mage_Adminhtml_Block_Template
25
+ {
26
+
27
+ public function getProduct()
28
+ {
29
+ $request = $this->getRequest();
30
+ $productId = $request->getParam('id');
31
+
32
+ $manufacturer = Mage::getModel('mybrand/manufacturer_product');
33
+ if($productId) {
34
+ $manufacturer->load($productId, 'product_id');
35
+ }
36
+
37
+ return $manufacturer;
38
+ }
39
+
40
+ public function getManufacturerCollection()
41
+ {
42
+ return Mage::getModel('mybrand/manufacturer')
43
+ ->getCollection()
44
+ ->addFieldToFilter('status', array('eq' => 1));
45
+ }
46
+ }
app/code/community/Displaze/MyBrand/Block/Adminhtml/Widget/Grid/Column/Renderer/Checkbox.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Checkbox.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Adminhtml_Widget_Grid_Column_Renderer_Checkbox extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Checkbox
25
+ {
26
+
27
+ /**
28
+ * we need a custom checkbox here, to add products to javascript Hash $H
29
+ */
30
+ protected function _getCheckboxHtml($value, $checked)
31
+ {
32
+ return '<input onClick="brandProduct.productGridCheckboxCheck(this)" type="checkbox" name="'.$this->getColumn()->getFieldName().'" value="' . $value . '" class="'. ($this->getColumn()->getInlineCss() ? $this->getColumn()->getInlineCss() : 'checkbox' ).'"/>';
33
+ }
34
+
35
+ }
app/code/community/Displaze/MyBrand/Block/Manufacturer.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Manufacturer.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Manufacturer extends Mage_Core_Block_Template
25
+ {
26
+
27
+ /**
28
+ * @todo canonical url has to be added to avoid duplication
29
+ */
30
+ protected function _prepareLayout()
31
+ {
32
+ parent::_prepareLayout();
33
+
34
+ if ($headBlock = $this->getLayout()->getBlock('head')) {
35
+
36
+ $manufacturer = $this->getManufacturer();
37
+
38
+ $headBlock->setTitle($manufacturer->getMetaTitle());
39
+ $headBlock->setDescription($manufacturer->getMetaDescription());
40
+ $headBlock->setKeywords($manufacturer->getMetaKeyword());
41
+
42
+ }
43
+ }
44
+
45
+ /**
46
+ * return current manufacturer which was added to registery in Displaze_MyBrand_ManufacturerController view action
47
+ *
48
+ * @return type
49
+ */
50
+ public function getManufacturer()
51
+ {
52
+ $manufacturer = Mage::registry('current_manufacturer');
53
+
54
+ if($manufacturer == null) {
55
+ $id = Mage::app()->getRequest()->getParam('id');
56
+ $manufacturer = Mage::getModel('mybrand/manufacturer')->load($id);
57
+ }
58
+
59
+ return $manufacturer;
60
+ }
61
+ }
app/code/community/Displaze/MyBrand/Block/Manufacturer/Link.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Link.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ /**
25
+ * For magento 1.6 this block needs to be called explicitly, for magento 1.7 and later
26
+ * no need to call this
27
+ */
28
+ class Displaze_MyBrand_Block_Manufacturer_Link extends Mage_Core_Block_Template
29
+ {
30
+ /**
31
+ * set the default template for this block,
32
+ */
33
+ public function _construct()
34
+ {
35
+ parent::_construct();
36
+ $this->setTemplate('displaze/mybrand/manufacturer/link.phtml');
37
+ }
38
+
39
+ /**
40
+ * Return all active/enabled manufacturers
41
+ * @return type
42
+ */
43
+ public function getManufacturerCollection()
44
+ {
45
+ return $manufacturerCollection = Mage::getModel('mybrand/manufacturer')
46
+ ->getCollection()
47
+ ->addFieldToFilter('status', array('eq' => 1));
48
+ }
49
+ }
app/code/community/Displaze/MyBrand/Block/Manufacturer/Product/List.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * List.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Manufacturer_Product_List extends Mage_Catalog_Block_Product_List
25
+ {
26
+ /**
27
+ * Retrieve loaded category collection
28
+ *
29
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
30
+ */
31
+ protected function _getProductCollection()
32
+ {
33
+ $productCollection = $this->getManufacturer()->getProductCollection();
34
+ return $productCollection;
35
+ }
36
+
37
+ /**
38
+ * Get array with product ids, which was added to manufacturer
39
+ *
40
+ * @return array
41
+ */
42
+ protected function _getManufacturerProductIds()
43
+ {
44
+ $manufacturer = $this->getManufacturer();
45
+ $productIds = array(0);
46
+ $productIds = $manufacturer->getProductIds();
47
+
48
+ return $productIds;
49
+ }
50
+
51
+ public function getManufacturer()
52
+ {
53
+ $manufacturer = Mage::registry('current_manufacturer');
54
+ if($manufacturer == null) {
55
+ $id = Mage::app()->getRequest()->getParam('id');
56
+ $manufacturer = Mage::getModel('mybrand/manufacturer')->load($id);
57
+ }
58
+
59
+ return $manufacturer;
60
+ }
61
+ }
app/code/community/Displaze/MyBrand/Block/Page/Html/Topmenu.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Navigation.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Block_Page_Html_Topmenu extends Mage_Page_Block_Html_Topmenu
25
+ {
26
+
27
+ public function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->setTemplate('displaze/mybrand/page/html/topmenu.phtml');
31
+ }
32
+
33
+
34
+ public function getManufacturerCollection()
35
+ {
36
+
37
+ return $manufacturerCollection = Mage::getModel('mybrand/manufacturer')
38
+ ->getCollection()
39
+ ->addFieldToFilter('status', array('eq' => 1));
40
+ }
41
+
42
+ /*
43
+ * This method has been overridden merely for the purpose of setting up a new view file
44
+ * to be used in place of the default theme folder.
45
+ *
46
+ * @reference http://inchoo.net/ecommerce/magento/how-to-override-magento-admin-view-template-files-quick-and-dirty-way/
47
+ *
48
+ * @see app/code/core/Mage/Core/Block/Mage_Core_Block_Template#fetchView($fileName)
49
+ */
50
+ public function fetchView($fileName)
51
+ {
52
+ extract($this->_viewVars);
53
+ $do = $this->getDirectOutput();
54
+ $html = '';
55
+ if (!$do) {
56
+ ob_start();
57
+ }
58
+ include getcwd() . '/app/design/frontend/default/default/template/displaze/mybrand/page/html/topmenu.phtml';
59
+
60
+ if (!$do) {
61
+ $html = ob_get_clean();
62
+ }
63
+ return $html;
64
+ }
65
+ }
app/code/community/Displaze/MyBrand/Controller/Router.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Router.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract
25
+ {
26
+ /**
27
+ * Initialize Controller Router
28
+ *
29
+ * @param Varien_Event_Observer $observer
30
+ */
31
+ public function initControllerRouters($observer)
32
+ {
33
+ /* @var $front Mage_Core_Controller_Varien_Front */
34
+ $front = $observer->getEvent()->getFront();
35
+
36
+ $front->addRouter('mybrand', $this);
37
+ }
38
+
39
+ /**
40
+ * Validate and Match MyLink Page and modify request
41
+ *
42
+ * @param Zend_Controller_Request_Http $request
43
+ * @return bool
44
+ */
45
+ public function match(Zend_Controller_Request_Http $request)
46
+ {
47
+ if (!Mage::isInstalled()) {
48
+ Mage::app()->getFrontController()->getResponse()
49
+ ->setRedirect(Mage::getUrl('install'))
50
+ ->sendResponse();
51
+ exit;
52
+ }
53
+
54
+ $identifier = trim($request->getPathInfo(), '/');
55
+
56
+ $condition = new Varien_Object(array(
57
+ 'identifier' => $identifier,
58
+ 'continue' => true
59
+ ));
60
+ Mage::dispatchEvent('mybrand_controller_router_match_before', array(
61
+ 'router' => $this,
62
+ 'condition' => $condition
63
+ ));
64
+ $identifier = $condition->getIdentifier();
65
+
66
+ if ($condition->getRedirectUrl()) {
67
+ Mage::app()->getFrontController()->getResponse()
68
+ ->setRedirect($condition->getRedirectUrl())
69
+ ->sendResponse();
70
+ $request->setDispatched(true);
71
+ return true;
72
+ }
73
+
74
+ if (!$condition->getContinue()) {
75
+ return false;
76
+ }
77
+
78
+ $manufacturer = Mage::getModel('mybrand/manufacturer');
79
+ $id = $manufacturer->checkIdentifier($identifier, Mage::app()->getStore()->getId());
80
+ if (!$id) {
81
+ return false;
82
+ }
83
+
84
+ $request->setModuleName('mybrand')
85
+ ->setControllerName('manufacturer')
86
+ ->setActionName('view')
87
+ ->setParam('id', $id);
88
+ $request->setAlias(
89
+ Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
90
+ $identifier
91
+ );
92
+
93
+ return true;
94
+ }
95
+ }
app/code/community/Displaze/MyBrand/Helper/Data.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Data.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Helper_Data extends Mage_Core_Helper_Abstract
25
+ {
26
+
27
+ public function getBrandMediaUrl()
28
+ {
29
+ return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'displaze/mybrand/';
30
+ }
31
+
32
+ public function getBrandMediaPath()
33
+ {
34
+ return Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . '/displaze/mybrand/';
35
+ }
36
+ }
app/code/community/Displaze/MyBrand/Helper/Manufacturer.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Manufacturer.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Helper_Manufacturer extends Mage_Core_Helper_Abstract
25
+ {
26
+
27
+ /**
28
+ * Render manufacturer products.
29
+ */
30
+ public function renderLink(Mage_Core_Controller_Varien_Action $action, $id)
31
+ {
32
+ $manufacturer = Mage::getSingleton('mybrand/manufacturer');
33
+ $manufacturer->setStoreId(Mage::app()->getStore()->getId());
34
+ if ($manufacturer->load($id)) {
35
+ return $manufacturer;
36
+ }
37
+ return false;
38
+ }
39
+
40
+ public function getUrl($identifier)
41
+ {
42
+ $baseUrl = Mage::getBaseUrl();
43
+
44
+ return $baseUrl . $identifier;
45
+ }
46
+ }
app/code/community/Displaze/MyBrand/Model/Manufacturer.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Manufacturer.php
4
+ *
5
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+ *
7
+ * This file is part of Displaze Web Services Inc..
8
+ *
9
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ */
22
+
23
+ class Displaze_MyBrand_Model_Manufacturer extends Mage_Core_Model_Abstract
24
+ {
25
+
26
+ /**
27
+ * Slide's Statuses
28
+ */
29
+ const STATUS_ENABLED = 1;
30
+ const STATUS_DISABLED = 0;
31
+
32
+
33
+ protected $_path = '';
34
+
35
+ /**
36
+ * Initialize resource model
37
+ *
38
+ */
39
+ protected function _construct()
40
+ {
41
+ $this->_init('mybrand/manufacturer');
42
+ }
43
+
44
+ /**
45
+ * get Manufacturer product collection for current manufacturer
46
+ */
47
+ public function getProductCollection()
48
+ {
49
+ $id = $this->getId();
50
+ return $this->_getResource()->getProductCollection($id);
51
+ }
52
+
53
+ /**
54
+ * Save Slideshow image.
55
+ */
56
+ public function saveImage()
57
+ {
58
+ if(isset($_FILES['logo']['name']) && (file_exists($_FILES['logo']['tmp_name']))) {
59
+
60
+ try {
61
+
62
+ $uploader = new Varien_File_Uploader('logo');
63
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png', 'bmp'));
64
+
65
+ $uploader->setAllowRenameFiles(true);
66
+ //$path = Mage::getBaseDir('media') . DS ;// 'displaze' . DS . 'myslideshow' . DS;
67
+ $path = $this->_initFolderStructure();
68
+
69
+ $uploader->save($path, $_FILES['logo']['name']);
70
+
71
+ $filename = $uploader->getUploadedFileName();
72
+ $this->setData('logo', $filename);
73
+
74
+
75
+ } catch(Exception $e) {
76
+
77
+ }
78
+ }
79
+
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * initialize folder structure if it does not exist.
85
+ * @return type
86
+ */
87
+ protected function _initFolderStructure()
88
+ {
89
+ $path = Mage::getBaseDir('media') . DS . 'displaze' . DS;
90
+ if(!is_dir($path)) {
91
+ mkdir($path, 0755);
92
+ }
93
+
94
+ $path = $path . 'mybrand' . DS;
95
+ if(!is_dir($path)) {
96
+ mkdir($path, 0755);
97
+ }
98
+
99
+ return $this->_path = $path;
100
+
101
+ }
102
+
103
+ public function save()
104
+ {
105
+ $deleteImage = Mage::app()->getRequest()->getPost('delete_image');
106
+ if($deleteImage) {
107
+
108
+ }
109
+
110
+ $this->saveImage();
111
+ parent::save();
112
+
113
+ return $this;
114
+ }
115
+
116
+
117
+ /**
118
+ * Prepare slide's statuses.
119
+ * Available event mybrand_manufacturer_get_available_statuses to customize statuses.
120
+ *
121
+ * @return array
122
+ */
123
+ public function getAvailableStatuses()
124
+ {
125
+ $statuses = new Varien_Object(array(
126
+ self::STATUS_ENABLED => Mage::helper('mybrand')->__('Enabled'),
127
+ self::STATUS_DISABLED => Mage::helper('mybrand')->__('Disabled'),
128
+ ));
129
+
130
+ Mage::dispatchEvent('mybrand_manufacturer_get_available_statuses', array('statuses' => $statuses));
131
+
132
+ return $statuses->getData();
133
+ }
134
+
135
+
136
+
137
+
138
+ /**
139
+ * Check if manufacturer identifier exist for specific store
140
+ * return manufacturer id if it exists
141
+ *
142
+ * @param string $identifier
143
+ * @param int $storeId
144
+ * @return int
145
+ */
146
+ public function checkIdentifier($identifier, $storeId)
147
+ {
148
+ return $this->_getResource()->checkIdentifier($identifier, $storeId);
149
+ }
150
+ }
app/code/community/Displaze/MyBrand/Model/Manufacturer/Product.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Product.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Model_Manufacturer_Product extends Mage_Core_Model_Abstract
25
+ {
26
+ /**
27
+ * Initialize resource model
28
+ *
29
+ */
30
+ protected function _construct()
31
+ {
32
+ $this->_init('mybrand/manufacturer_product');
33
+ }
34
+
35
+ public function addManufacturerIdFilter($manufacturerId)
36
+ {
37
+ return $this->_getResource()->addManufacturerIdFilter($manufacturerId);
38
+ }
39
+ }
app/code/community/Displaze/MyBrand/Model/Observer/Product.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+
4
+ /*
5
+ * Product.php
6
+ *
7
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
8
+ *
9
+ * This file is part of Displaze Web Services Inc..
10
+ *
11
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
12
+ * it under the terms of the GNU General Public License as published by
13
+ * the Free Software Foundation, either version 3 of the License, or
14
+ * (at your option) any later version.
15
+ *
16
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU General Public License
22
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
23
+ */
24
+
25
+ class Displaze_MyBrand_Model_Observer_Product
26
+ {
27
+
28
+ /**
29
+ * Inject one tab into the product edit page in the Magento admin
30
+ *
31
+ * @param Varien_Event_Observer $observer
32
+ */
33
+ public function injectTabs(Varien_Event_Observer $observer)
34
+ {
35
+ $block = $observer->getEvent()->getBlock();
36
+
37
+ $request = Mage::app()->getRequest();
38
+
39
+ if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs) {
40
+ if ($request->getActionName() == 'edit' || $request->getParam('type')) {
41
+ $block->addTab('mybrand-manufacturer-tab', array(
42
+ 'label' => 'Manufacturer',
43
+ 'content' => $block->getLayout()->createBlock('mybrand/adminhtml_manufacturer_tab', 'mybrand-manufacturer-tab-content', array('template' => 'displaze/mybrand/manufacturer/tab.phtml'))->toHtml(),
44
+ ));
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * This method will run when the product is saved
51
+ * Use this function to update the product model and save
52
+ *
53
+ * @param Varien_Event_Observer $observer
54
+ */
55
+ public function saveTabData(Varien_Event_Observer $observer) {
56
+
57
+ $request = Mage::app()->getRequest();
58
+ if ($request->getParam('manufacturer_id') > 0) {
59
+ try {
60
+ // Load the current product model
61
+ $product = Mage::registry('product');
62
+
63
+ // 2 load manufacturer product model and delete it
64
+ $manufacturerProduct = Mage::getModel('mybrand/manufacturer_product');
65
+ $manufacturerProduct->load($product->getId(), 'product_id');
66
+ $manufacturerProduct->delete();
67
+
68
+ // 3 save the product against the manufacturer
69
+ $manufacturerProduct->setData(
70
+ array(
71
+ 'product_id' => $product->getId(),
72
+ 'manufacturer_id' => $request->getParam('manufacturer_id')
73
+ )
74
+ );
75
+
76
+ $manufacturerProduct->save();
77
+
78
+ } catch (Exception $e) {
79
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
80
+ }
81
+ }
82
+ }
83
+
84
+ }
app/code/community/Displaze/MyBrand/Model/Resource/Manufacturer.php ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Manufacturer.php
4
+ *
5
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+ *
7
+ * This file is part of Displaze Web Services Inc..
8
+ *
9
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ */
22
+
23
+ class Displaze_MyBrand_Model_Resource_Manufacturer extends Mage_Core_Model_Resource_Db_Abstract
24
+ {
25
+ /**
26
+ * Store model
27
+ *
28
+ * @var null|Mage_Core_Model_Store
29
+ */
30
+ protected $_store = null;
31
+
32
+ /**
33
+ * Initialize resource model
34
+ *
35
+ */
36
+ protected function _construct()
37
+ {
38
+ $this->_init('mybrand/manufacturer', 'id');
39
+ }
40
+
41
+ /**
42
+ * Process page data before saving
43
+ *
44
+ * @param Mage_Core_Model_Abstract $object
45
+ * @return Displaze_MySlideshow_Model_Resource_Slideshow
46
+ */
47
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
48
+ {
49
+ /*
50
+ * For two attributes which represent timestamp data in DB
51
+ * we should make converting such as:
52
+ * If they are empty we need to convert them into DB
53
+ * type NULL so in DB they will be empty and not some default value
54
+ */
55
+ foreach (array('activation_time_from', 'activation_time_to') as $field) {
56
+ $value = !$object->getData($field) ? null : $object->getData($field);
57
+ $object->setData($field, $this->formatDate($value));
58
+ }
59
+
60
+ if (!$this->getIsUniqueManufacturerToStores($object)) {
61
+ Mage::throwException(Mage::helper('mybrand')->__('A manufacturer URL key for specified store already exists.'));
62
+ }
63
+
64
+ if (!$this->isValidManufacturerIdentifier($object)) {
65
+ Mage::throwException(Mage::helper('mybrand')->__('The manufacturer URL key contains capital letters or disallowed symbols.'));
66
+ }
67
+
68
+ if ($this->isNumericManufacturerIdentifier($object)) {
69
+ Mage::throwException(Mage::helper('mybrand')->__('The manufacturer URL key cannot consist only of numbers.'));
70
+ }
71
+
72
+ // modify create / update dates
73
+ if ($object->isObjectNew() && !$object->hasCreationTime()) {
74
+ $object->setCreationTime(Mage::getSingleton('core/date')->gmtDate());
75
+ }
76
+
77
+
78
+ $object->setUpdateTime(Mage::getSingleton('core/date')->gmtDate());
79
+
80
+ return parent::_beforeSave($object);
81
+ }
82
+
83
+
84
+ /**
85
+ * Assign page to store views
86
+ *
87
+ */
88
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
89
+ {
90
+ $oldStores = $this->lookupStoreIds($object->getId());
91
+ $newStores = (array)$object->getStores();
92
+ if (empty($newStores)) {
93
+ $newStores = (array)$object->getStoreId();
94
+ }
95
+ $table = $this->getTable('mybrand/manufacturer_store');
96
+ $insert = array_diff($newStores, $oldStores);
97
+ $delete = array_diff($oldStores, $newStores);
98
+
99
+ if ($delete) {
100
+ $where = array(
101
+ 'manufacturer_id = ?' => (int) $object->getId(),
102
+ 'store_id IN (?)' => $delete
103
+ );
104
+
105
+ $this->_getWriteAdapter()->delete($table, $where);
106
+ }
107
+
108
+ if ($insert) {
109
+ $data = array();
110
+
111
+ foreach ($insert as $storeId) {
112
+ $data[] = array(
113
+ 'manufacturer_id' => (int) $object->getId(),
114
+ 'store_id' => (int) $storeId
115
+ );
116
+ }
117
+
118
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
119
+ }
120
+
121
+ $this->_saveProducts($object); //save manufacturer products if any
122
+ return parent::_afterSave($object);
123
+ }
124
+
125
+ /**
126
+ * save products associated with this manufacturer
127
+ * @return Renegade_MyBrand_Model_Resource_Manufacturer $link
128
+ */
129
+ protected function _saveProducts(Mage_Core_Model_Abstract $object)
130
+ {
131
+ $condition = $this->_getWriteAdapter()->quoteInto('manufacturer_id = ?', $object->getId());
132
+ $this->_getWriteAdapter()->delete($this->getTable('mybrand/manufacturer_product'), $condition);
133
+
134
+ foreach((array)$object->getData('product') as $productArray) {
135
+ //product_id and product_sku is already included in $productArray so we don't need to explicitly assign those, like below manufacturer_id
136
+ $productArray['manufacturer_id'] = $object->getId();
137
+ $this->_getWriteAdapter()->insert($this->getTable('mybrand/manufacturer_product'), $productArray);
138
+ }
139
+
140
+ return $this;
141
+ }
142
+
143
+
144
+ /* _afterLoad is called when the collection is loaded.
145
+ * Appends the data with ManufacturerCollection for Store
146
+ * @param Mage_Core_Model_Abstract $object
147
+ */
148
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
149
+ {
150
+ $select = $this->_getReadAdapter()->select()
151
+ ->from($this->getTable('mybrand/manufacturer_store'))
152
+ ->where('manufacturer_id = ?', $object->getId());
153
+
154
+ if ($data = $this->_getReadAdapter()->fetchAll($select)) {
155
+ $storesArray = array();
156
+ foreach ($data as $row) {
157
+ $storesArray[] = $row['store_id'];
158
+ }
159
+ $object->setData('store_id', $storesArray);
160
+ }
161
+
162
+ $this->_getProductIds($object); //append product ids with current link collection
163
+
164
+ return parent::_afterLoad($object);
165
+ }
166
+
167
+ /**
168
+ * Retrieves brand manufacturer identifier from DB by passed id.
169
+ *
170
+ * @param string $id
171
+ * @return string|false
172
+ */
173
+ public function getManufacturerIdentifierById($id)
174
+ {
175
+ $adapter = $this->_getReadAdapter();
176
+
177
+ $select = $adapter->select()
178
+ ->from($this->getMainTable(), 'identifier')
179
+ ->where('id = :id');
180
+
181
+ $binds = array(
182
+ 'id' => (int) $id
183
+ );
184
+
185
+ return $adapter->fetchOne($select, $binds);
186
+ }
187
+
188
+
189
+ /**
190
+ * get Manufacturer product collection for current manufacturer
191
+ */
192
+ public function getProductCollection($manufacturerId)
193
+ {
194
+ $id = $manufacturerId;
195
+
196
+ $table = $this->getTable('mybrand/manufacturer_product'); //manufacturer products
197
+
198
+ $adapter = $this->_getReadAdapter();
199
+
200
+ $select = $adapter->select()
201
+ ->from(array('main_table' => $this->getMainTable()), 'id')
202
+ ->where('main_table.id = :id');
203
+
204
+ $select->join(
205
+ array('related' => $table),
206
+ 'main_table.id = related.manufacturer_id'
207
+ );
208
+
209
+ $binds = array(
210
+ 'id' => (int) $id
211
+ );
212
+
213
+ $productIds = array();
214
+ foreach($adapter->fetchAll($select, $binds) as $product) {
215
+ $productIds[] = $product['product_id'];
216
+ }
217
+
218
+ $productCollection = Mage::getModel('catalog/product')
219
+ ->getCollection()
220
+ ->addAttributeToSelect('*')
221
+ ->addAttributeToFilter('entity_id', array('in' => $productIds));
222
+
223
+
224
+ return $productCollection;
225
+
226
+ }
227
+
228
+ protected function _getProductIds(Mage_Core_Model_Abstract $object)
229
+ {
230
+ $select = $this->_getReadAdapter()->select()
231
+ ->from($this->getTable('mybrand/manufacturer_product'))
232
+ ->where('manufacturer_id = ?', $object->getId());
233
+
234
+ if($data = $this->_getReadAdapter()->fetchAll($select)) {
235
+ $productArray = array();
236
+ foreach($data as $row) {
237
+ $productArray[] = $row['product_id'];
238
+ }
239
+ $object->setData('product_ids', $productArray);
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Get store ids to which specified item is assigned
245
+ *
246
+ * @param int $id
247
+ * @return array
248
+ */
249
+ public function lookupStoreIds($manufacturerId)
250
+ {
251
+ $adapter = $this->_getReadAdapter();
252
+
253
+ $select = $adapter->select()
254
+ ->from($this->getTable('mybrand/manufacturer_store'), 'store_id')
255
+ ->where('manufacturer_id = ?',(int)$manufacturerId);
256
+
257
+ return $adapter->fetchCol($select);
258
+ }
259
+
260
+
261
+ /**
262
+ * Check for unique of identifier of manufacturer to selected store(s).
263
+ *
264
+ * @param Mage_Core_Model_Abstract $object
265
+ * @return bool
266
+ */
267
+ public function getIsUniqueManufacturerToStores(Mage_Core_Model_Abstract $object)
268
+ {
269
+ if (Mage::app()->isSingleStoreMode() || !$object->hasStores()) {
270
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
271
+ } else {
272
+ $stores = (array)$object->getData('stores');
273
+ }
274
+
275
+ $select = $this->_getLoadByIdentifierSelect($object->getData('identifier'), $stores);
276
+
277
+ if ($object->getId()) {
278
+ $select->where('bms.manufacturer_id <> ?', $object->getId());
279
+ }
280
+
281
+ if ($this->_getWriteAdapter()->fetchRow($select)) {
282
+ return false;
283
+ }
284
+
285
+ return true;
286
+ }
287
+
288
+ /**
289
+ * Retrieve load select with filter by identifier, store and activity
290
+ *
291
+ * @param string $identifier
292
+ * @param int|array $store
293
+ * @param int $isActive
294
+ * @return Varien_Db_Select
295
+ */
296
+ protected function _getLoadByIdentifierSelect($identifier, $store, $isActive = null)
297
+ {
298
+ $select = $this->_getReadAdapter()->select()
299
+ ->from(array('bm' => $this->getMainTable()))
300
+ ->join(
301
+ array('bms' => $this->getTable('mybrand/manufacturer_store')),
302
+ 'bm.id = bms.manufacturer_id',
303
+ array())
304
+ ->where('bm.identifier = ?', $identifier)
305
+ ->where('bms.store_id IN (?)', $store);
306
+
307
+ if (!is_null($isActive)) {
308
+ $select->where('bm.status = ?', $isActive);
309
+ }
310
+
311
+ return $select;
312
+ }
313
+
314
+ /**
315
+ * Check whether manufacturer identifier is numeric
316
+ *
317
+ * @param Mage_Core_Model_Abstract $object
318
+ * @return bool
319
+ */
320
+ protected function isNumericManufacturerIdentifier(Mage_Core_Model_Abstract $object)
321
+ {
322
+ return preg_match('/^[0-9]+$/', $object->getData('identifier'));
323
+ }
324
+
325
+ /**
326
+ * Check whether manufacturer identifier is valid
327
+ *
328
+ * @param Mage_Core_Model_Abstract $object
329
+ * @return bool
330
+ */
331
+ protected function isValidManufacturerIdentifier(Mage_Core_Model_Abstract $object)
332
+ {
333
+ return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('identifier'));
334
+ }
335
+
336
+ /**
337
+ * Check if manufacturer identifier exist for specific store
338
+ * return manufacturer id if page exists
339
+ *
340
+ * @param string $identifier
341
+ * @param int $storeId
342
+ * @return int
343
+ */
344
+ public function checkIdentifier($identifier, $storeId)
345
+ {
346
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID, $storeId);
347
+ $select = $this->_getLoadByIdentifierSelect($identifier, $stores, 1);
348
+ $select->reset(Zend_Db_Select::COLUMNS)
349
+ ->columns('bm.id')
350
+ ->order('bms.store_id DESC')
351
+ ->limit(1);
352
+
353
+ return $this->_getReadAdapter()->fetchOne($select);
354
+ }
355
+ }
app/code/community/Displaze/MyBrand/Model/Resource/Manufacturer/Collection.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Collection.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Model_Resource_Manufacturer_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
25
+ {
26
+ /**
27
+ * Load data for preview flag
28
+ *
29
+ * @var bool
30
+ */
31
+ protected $_previewFlag;
32
+
33
+
34
+ /**
35
+ * Define resource model
36
+ *
37
+ */
38
+ protected function _construct()
39
+ {
40
+ $this->_init('mybrand/manufacturer');
41
+ //$this->_map['fields']['page_id'] = 'main_table.page_id';
42
+ //$this->_map['fields']['store'] = 'store_table.store_id';
43
+ }
44
+ }
app/code/community/Displaze/MyBrand/Model/Resource/Manufacturer/Product.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Product.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Model_Resource_Manufacturer_Product extends Mage_Core_Model_Resource_Db_Abstract
25
+ {
26
+ /**
27
+ * Initialize resource model
28
+ *
29
+ */
30
+ protected function _construct()
31
+ {
32
+ $this->_init('mybrand/manufacturer_product', 'id');
33
+ }
34
+
35
+ /**
36
+ * Retrieve related products
37
+ *
38
+ * @return array
39
+ */
40
+ public function addManufacturerIdFilter($manufacturerId)
41
+ {
42
+ $manufacturerTable = $this->getTable('mybrand/manufacturer');
43
+
44
+ $adapter = $this->_getReadAdapter();
45
+
46
+ $select = $adapter->select()
47
+ ->from(array('main_table' => $this->getMainTable()), 'manufacturer_id')
48
+ ->where('main_table.manufacturer_id = ?',(int)$manufacturerId);
49
+
50
+ $select->join(
51
+ array('related' => $manufacturerTable ),
52
+ 'main_table.manufacturer_id = related.id'
53
+ )->order('related.id');
54
+
55
+ echo $select;exit;
56
+ return $this;
57
+ }
58
+ }
app/code/community/Displaze/MyBrand/controllers/Adminhtml/ManufacturerController.php ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ItemController.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_Adminhtml_ManufacturerController extends Mage_Adminhtml_Controller_Action
25
+ {
26
+
27
+ protected function _construct()
28
+ {
29
+ $this->setUsedModuleName('Displaze_MyBrand');
30
+ }
31
+
32
+ protected function _initAction()
33
+ {
34
+ $this->loadLayout()
35
+ ->_setActiveMenu('displaze')
36
+ ->_addBreadcrumb(Mage::helper('mybrand')->__('Manufacturer'), Mage::helper('mybrand')->__('Manufacturer'))
37
+ ->_addBreadcrumb(Mage::helper('mybrand')->__('Manage Manufacturer'), Mage::helper('mybrand')->__('Manage Manufacturer'));
38
+ return $this;
39
+ }
40
+
41
+
42
+ /**
43
+ * Action layout is defined in adminhtml/mybrand.xml
44
+ */
45
+ public function indexAction()
46
+ {
47
+ $this->_initAction();
48
+ //layout is loaded from xml file.
49
+ $this->renderLayout();
50
+ }
51
+
52
+ public function editAction()
53
+ {
54
+ $this->_title($this->__('Displaze MyBrand'))
55
+ ->_title($this->__('Manufactuer'));
56
+
57
+
58
+
59
+ // 1. Get ID and create model
60
+ $id = $this->getRequest()->getParam('id');
61
+ $model = Mage::getModel('mybrand/manufacturer');
62
+
63
+ // 2. Initial checking
64
+ if ($id) {
65
+ $model->load($id);
66
+ if (!$model->getId()) {
67
+ Mage::getSingleton('adminhtml/session')->addError(
68
+ Mage::helper('mybrand')->__('This manufacturer no longer exists.'));
69
+ $this->_redirect('*/*/');
70
+ return;
71
+ }
72
+ }
73
+
74
+ $this->_title($model->getId() ? $model->getTitle() : $this->__('New Manufacturer'));
75
+
76
+ // 3. Set entered data if was error when we do save
77
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
78
+ if (! empty($data)) {
79
+ $model->setData($data);
80
+ }
81
+
82
+ // 4. Register model to use later in blocks
83
+ Mage::register('mybrand_manufacturer', $model);
84
+
85
+ // 5. Build edit form
86
+ $this->_initAction()
87
+ ->_addBreadcrumb(
88
+ $id ? Mage::helper('mybrand')->__('Edit Manufacturer')
89
+ : Mage::helper('mybrand')->__('New Manufacturer'),
90
+ $id ? Mage::helper('mybrand')->__('Edit Manufacturer')
91
+ : Mage::helper('mybrand')->__('New Manufacturer'));
92
+
93
+ $this->renderLayout();
94
+ }
95
+
96
+
97
+ public function newAction()
98
+ {
99
+ $this->_forward('edit');
100
+ }
101
+
102
+ /**
103
+ * save manufacturer
104
+ */
105
+ public function saveAction()
106
+ {
107
+ // check if data sent
108
+ if ($data = $this->getRequest()->getPost()) {
109
+ $data = $this->_filterPostData($data);
110
+ //init model and set data
111
+ $model = Mage::getModel('mybrand/manufacturer');
112
+
113
+ if ($id = $this->getRequest()->getParam('id')) {
114
+ $model->load($id);
115
+ }
116
+
117
+ $model->setData($data);
118
+
119
+ Mage::dispatchEvent('mybrand_manufacturer_prepare_save', array('manufacturer' => $model, 'request' => $this->getRequest()));
120
+
121
+ //validating
122
+ //if (!$this->_validatePostData($data)) {
123
+ // $this->_redirect('*/*/edit', array('id' => $model->getId(), '_current' => true));
124
+ // return;
125
+ //}
126
+
127
+ // try to save it
128
+ try {
129
+ // save the data
130
+ $model->save();
131
+
132
+ // display success message
133
+ Mage::getSingleton('adminhtml/session')->addSuccess(
134
+ Mage::helper('mybrand')->__('The manufacturer has been saved.'));
135
+ // clear previously saved data from session
136
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
137
+ // check if 'Save and Continue'
138
+ if ($this->getRequest()->getParam('back')) {
139
+ $this->_redirect('*/*/edit', array('id' => $model->getId(), '_current'=>true));
140
+ return;
141
+ }
142
+ // go to grid
143
+ $this->_redirect('*/*/');
144
+ return;
145
+
146
+ } catch (Mage_Core_Exception $e) {
147
+ $this->_getSession()->addError($e->getMessage());
148
+ }
149
+ catch (Exception $e) {
150
+ $this->_getSession()->addException($e,
151
+ Mage::helper('mybrand')->__('An error occurred while saving the manufacturer.'));
152
+ }
153
+
154
+ $this->_getSession()->setFormData($data);
155
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
156
+ return;
157
+ }
158
+ $this->_redirect('*/*/');
159
+ }
160
+
161
+ /**
162
+ * Filtering posted data. Converting localized data if needed
163
+ *
164
+ * @param array
165
+ * @return array
166
+ */
167
+ protected function _filterPostData($data)
168
+ {
169
+ $data = $this->_filterDates($data, array('activation_time_from', 'activation_time_to'));
170
+ return $data;
171
+ }
172
+
173
+
174
+ /**
175
+ * Grid with available products for Brand Manufacturer
176
+ * This action is bind with any grid related events like sorting and
177
+ * filtering of products.
178
+ *
179
+ */
180
+ public function gridAction()
181
+ {
182
+ $this->loadLayout();
183
+ $this->getResponse()->setBody(
184
+ $this->getLayout()
185
+ ->createBlock('mybrand/adminhtml_manufacturer_edit_tab_product_grid')
186
+ ->setIndex($this->getRequest()->getParam('index'))
187
+ ->toHtml()
188
+ );
189
+ }
190
+
191
+ /**
192
+ * Delete action
193
+ */
194
+ public function deleteAction()
195
+ {
196
+ // check if we know what should be deleted
197
+ if ($id = $this->getRequest()->getParam('id')) {
198
+ $title = "";
199
+ try {
200
+ // init model and delete
201
+ $model = Mage::getModel('mybrand/manufacturer');
202
+ $model->load($id);
203
+ $title = $model->getTitle();
204
+ //delete image before deleting the record
205
+ $logo = Mage::helper('mybrand')->getBrandMediaPath() . $model->getLogo();
206
+ @unlink($logo);
207
+
208
+ $model->delete();
209
+ // display success message
210
+ $message = sprintf(Mage::helper('mybrand')->__('The %s manufactuerer has been deleted.'), $title);
211
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
212
+ // go to grid
213
+ Mage::dispatchEvent('mybrand_manufacturer_on_delete', array('title' => $title, 'status' => 'success'));
214
+ $this->_redirect('*/*/');
215
+ return;
216
+
217
+ } catch (Exception $e) {
218
+ Mage::dispatchEvent('mybrand_manufacturer_on_delete', array('title' => $title, 'status' => 'fail'));
219
+ // display error message
220
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
221
+ // go back to edit form
222
+ $this->_redirect('*/*/edit', array('id' => $id));
223
+ return;
224
+ }
225
+ }
226
+ // display error message
227
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mybrand')->__('Unable to find a manufacturer to delete.'));
228
+ // go to grid
229
+ $this->_redirect('*/*/');
230
+ }
231
+
232
+ }
app/code/community/Displaze/MyBrand/controllers/ManufacturerController.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ManufacturerController.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ class Displaze_MyBrand_ManufacturerController extends Mage_Core_Controller_Front_Action
25
+ {
26
+ /**
27
+ * list products for current manufacturer
28
+ */
29
+ public function viewAction()
30
+ {
31
+ $this->loadLayout();
32
+ try {
33
+ $id = $this->getRequest()->getParam('id', $this->getRequest()->getParam('id', false));
34
+
35
+ if($manufacturer = Mage::helper('mybrand/manufacturer')->renderLink($this, $id)) {
36
+ //register current manufacturer
37
+ Mage::register('current_manufacturer', $manufacturer);
38
+
39
+ }
40
+ } catch(Exception $e) {
41
+
42
+ }
43
+
44
+ $this->renderLayout();
45
+ }
46
+ }
app/code/community/Displaze/MyBrand/etc/adminhtml.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ adminhtml.xml
4
+
5
+ Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+
7
+ This file is part of Displaze Web Services Inc..
8
+
9
+ Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ -->
22
+
23
+
24
+ <adminhtml>
25
+ <menu>
26
+ <displaze module="mybrand">
27
+ <title>Displaze</title>
28
+ <sort_order>39</sort_order>
29
+ <children>
30
+ <mybrand module="mybrand">
31
+ <title>Brand Management</title>
32
+ <sort_order>2</sort_order>
33
+ <action>/manufacturer/index</action>
34
+ </mybrand>
35
+ </children>
36
+ </displaze>
37
+ </menu>
38
+
39
+
40
+
41
+ </adminhtml>
app/code/community/Displaze/MyBrand/etc/config.xml ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ config.xml
4
+
5
+ Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+
7
+ This file is part of Displaze Web Services Inc..
8
+
9
+ Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ -->
22
+
23
+ <config>
24
+ <modules>
25
+ <Displaze_MyBrand>
26
+ <version>1.7.0</version>
27
+ </Displaze_MyBrand>
28
+ </modules>
29
+
30
+ <global>
31
+
32
+ <blocks>
33
+ <mybrand>
34
+ <class>Displaze_MyBrand_Block</class>
35
+ </mybrand>
36
+
37
+ <!--@Override Navigation Block to include shopby brand menu -->
38
+ <page>
39
+ <rewrite>
40
+ <html_topmenu>Displaze_MyBrand_Block_Page_Html_Topmenu</html_topmenu>
41
+ </rewrite>
42
+ </page>
43
+
44
+ </blocks>
45
+
46
+ <models>
47
+ <mybrand>
48
+ <class>Displaze_MyBrand_Model</class>
49
+ <resourceModel>mybrand_resource</resourceModel>
50
+ </mybrand>
51
+
52
+ <mybrand_resource>
53
+ <class>Displaze_MyBrand_Model_Resource</class>
54
+ <entities>
55
+ <manufacturer>
56
+ <table>displaze_mybrand_manufacturer</table>
57
+ </manufacturer>
58
+ <manufacturer_product>
59
+ <table>displaze_mybrand_manufacturer_product</table>
60
+ </manufacturer_product>
61
+ <manufacturer_store>
62
+ <table>displaze_mybrand_manufacturer_store</table>
63
+ </manufacturer_store>
64
+ </entities>
65
+ </mybrand_resource>
66
+ </models>
67
+
68
+ <!-- used for installation/entry in core_resource table -->
69
+ <resources>
70
+ <mybrand_setup>
71
+ <setup>
72
+ <module>Displaze_MyBrand</module>
73
+ </setup>
74
+ </mybrand_setup>
75
+ </resources>
76
+
77
+ <helpers>
78
+ <mybrand>
79
+ <class>Displaze_MyBrand_Helper</class>
80
+ </mybrand>
81
+ </helpers>
82
+
83
+ <!--@Register Frontend Router for MyBrand -->
84
+ <events>
85
+ <controller_front_init_routers>
86
+ <observers>
87
+ <mybrand>
88
+ <class>Displaze_MyBrand_Controller_Router</class>
89
+ <method>initControllerRouters</method>
90
+ </mybrand>
91
+ </observers>
92
+ </controller_front_init_routers>
93
+ </events>
94
+
95
+ </global>
96
+
97
+ <!--Admin controller router Configuration -->
98
+ <admin>
99
+ <routers>
100
+ <adminhtml>
101
+ <args>
102
+ <modules>
103
+ <Displaze_MyBrand before="Mage_Adminhtml">Displaze_MyBrand_Adminhtml</Displaze_MyBrand>
104
+ </modules>
105
+ </args>
106
+ </adminhtml>
107
+ </routers>
108
+ </admin>
109
+
110
+ <frontend>
111
+ <routers>
112
+ <mybrand>
113
+ <use>standard</use>
114
+ <args>
115
+ <module>Displaze_MyBrand</module>
116
+ <frontName>mybrand</frontName>
117
+ </args>
118
+ </mybrand>
119
+ </routers>
120
+ <!--@frontend layout file -->
121
+ <layout>
122
+ <updates>
123
+ <mybrand>
124
+ <file>displaze/mybrand.xml</file>
125
+ </mybrand>
126
+ </updates>
127
+ </layout>
128
+ </frontend>
129
+
130
+ <adminhtml>
131
+ <layout>
132
+ <updates>
133
+ <mybrand>
134
+ <file>displaze/mybrand.xml</file>
135
+ </mybrand>
136
+ </updates>
137
+ </layout>
138
+
139
+ <!--There are two event observers :
140
+ 1. first one to shoot when the product edit tabs are generated, this one will inject a tab for product family.
141
+ 2. Second observers will shoot when ever a product is saved, it will insert any data that might be set/edited in custom product family tab, in the product mangement ( magento admin or backend).
142
+ */
143
+ -->
144
+ <!-- Below will be implemented in next version this version will not have an product tab
145
+ <events>
146
+ <core_block_abstract_prepare_layout_after>
147
+ <observers>
148
+ <displaze_mybrand_product_injectTabs>
149
+ <type>singleton</type>
150
+ <class>mybrand/observer_product</class>
151
+ <method>injectTabs</method>
152
+ </displaze_mybrand_product_injectTabs>
153
+ </observers>
154
+ </core_block_abstract_prepare_layout_after>
155
+ <catalog_product_save_after>
156
+ <observers>
157
+ <displaze_mybrand_save_product_data>
158
+ <type>singleton</type>
159
+ <class>mybrand/observer_product</class>
160
+ <method>saveTabData</method>
161
+ </displaze_mybrand_save_product_data>
162
+ </observers>
163
+ </catalog_product_save_after>
164
+ </events> -->
165
+ </adminhtml>
166
+
167
+ </config>
app/code/community/Displaze/MyBrand/sql/mybrand_setup/install-1.7.0.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * install-1.7.0.php
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+
24
+ /* @var $installer Mage_Core_Model_Resource_Setup */
25
+ $installer = $this;
26
+
27
+ $installer->startSetup();
28
+
29
+ /**
30
+ * Create table 'myslideshow/slideshow'
31
+ */
32
+ $table = $installer->getConnection()
33
+ ->newTable($installer->getTable('mybrand/manufacturer'))
34
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
35
+ 'identity' => true,
36
+ 'nullable' => false,
37
+ 'primary' => true,
38
+ ), 'Manufacturer ID')
39
+ ->addColumn('title', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
40
+ 'nullable' => false,
41
+ ), 'Manufacturer Title')
42
+ ->addColumn('identifier', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
43
+ 'nullable' => false,
44
+ ), 'Manufacturer Url Key')
45
+ ->addColumn('logo', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
46
+ 'nullable' => true,
47
+ ), 'Manufacturer Logo')
48
+ ->addColumn('cover_image', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
49
+ 'nullable' => true,
50
+ ), 'Manufacturer Cover Image')
51
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
52
+ 'nullable' => false,
53
+ 'default' => '1',
54
+ ), 'Manufacturer Status')
55
+ ->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
56
+ 'nullable' => true,
57
+ ), 'Manufacturer Content')
58
+ ->addColumn('meta_title', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
59
+ 'nullable' => true,
60
+ ), 'Manufacturer Meta Title')
61
+ ->addColumn('meta_keyword', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
62
+ 'nullable' => true,
63
+ ), 'Manufacturer Keywords')
64
+ ->addColumn('meta_description', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
65
+ 'nullable' => true,
66
+ ), 'Manufacturer Keywords')
67
+ ->addColumn('creation_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
68
+ ), 'Manufacturer Creation Time')
69
+ ->addColumn('update_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
70
+ ), 'Manufacturer Modification Time')
71
+
72
+ /* ->addColumn('activation_time_from', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
73
+ ), 'Manufactuer Activation Time From')
74
+
75
+ ->addColumn('activation_time_to', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
76
+ ), 'Manufactuer Activation Time To') */
77
+ ->setComment('Displaze MyBrand Manufacturer Table');
78
+
79
+ $installer->getConnection()->createTable($table);
80
+
81
+ /**
82
+ * Create table 'mybrand/manufacturer_store'
83
+ */
84
+ $table = $installer->getConnection()
85
+ ->newTable($installer->getTable('mybrand/manufacturer_store'))
86
+ ->addColumn('manufacturer_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
87
+ 'nullable' => false,
88
+ 'primary' => true,
89
+ ), 'Manufacturer ID')
90
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
91
+ 'unsigned' => true,
92
+ 'nullable' => false,
93
+ 'primary' => true,
94
+ ), 'Store ID')
95
+ ->addIndex($installer->getIdxName('mybrand/manufacturer_store', array('store_id')),
96
+ array('store_id'))
97
+ ->addForeignKey($installer->getFkName('mybrand/manufacturer_store', 'manufacturer_id', 'mybrand/manufacturer', 'id'),
98
+ 'manufacturer_id', $installer->getTable('mybrand/manufacturer'), 'id',
99
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
100
+ ->addForeignKey($installer->getFkName('mybrand/manufacturer_store', 'store_id', 'core/store', 'store_id'),
101
+ 'store_id', $installer->getTable('core/store'), 'store_id',
102
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
103
+ ->setComment('MyBrand Manufacturer To Store Linkage Table');
104
+ $installer->getConnection()->createTable($table);
105
+
106
+ /**
107
+ * Create table mybrand/manufacturer_product
108
+ */
109
+
110
+ $table = $installer->getConnection()
111
+ ->newTable($installer->getTable('mybrand/manufacturer_product'))
112
+ ->addColumn('manufacturer_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
113
+ 'nullable' => false
114
+
115
+ ), 'Manufacturer ID')
116
+
117
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
118
+ 'nullable' => true,
119
+ 'unasigned' => true
120
+ ), 'Product ID')
121
+
122
+ ->addColumn('product_sku', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
123
+ 'nullable' => true,
124
+ ), 'Manufacturer Product Sku')
125
+
126
+ ->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
127
+ 'unsigned' => true,
128
+ 'nullable' => false,
129
+ 'default' => '0',
130
+ ), 'Position')
131
+
132
+ ->addIndex($installer->getIdxName('mybrand/manufacturer_product', array('manufacturer_id')), array('manufacturer_id'))
133
+ ->addIndex($installer->getIdxName('mybrand/manufacturer_product', array('product_id')), array('product_id'))
134
+
135
+ ->addForeignKey($installer->getFkName('mybrand/manufacturer_product', 'product_id', 'catalog/product', 'entity_id'),
136
+ 'product_id', $installer->getTable('catalog/product'), 'entity_id',
137
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
138
+
139
+ ->addForeignKey($installer->getFkName('mybrand/manufacturer_product', 'manufacturer_id', 'mybrand/manufacturer', 'id'),
140
+ 'manufacturer_id', $installer->getTable('mybrand/manufacturer'), 'id',
141
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
142
+
143
+ ->setComment('Manufacturer Product');
144
+
145
+ $installer->getConnection()->createTable($table);
146
+
147
+ $installer->endSetup();
148
+
149
+
app/design/adminhtml/default/default/layout/displaze/mybrand.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ mybrand.xml
4
+
5
+ Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+
7
+ This file is part of Displaze Web Services Inc..
8
+
9
+ Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ -->
22
+
23
+
24
+ <layout version="1.0">
25
+
26
+ <adminhtml_manufacturer_index>
27
+ <reference name="content">
28
+ <block type="mybrand/adminhtml_manufacturer" name="manufacturer.grid" />
29
+ </reference>
30
+ </adminhtml_manufacturer_index>
31
+
32
+ <!--Edit Area -->
33
+ <adminhtml_manufacturer_edit>
34
+
35
+ <reference name="content">
36
+ <block type="mybrand/adminhtml_manufacturer_edit" name="displaze.manufacturer.edit"></block>
37
+ </reference>
38
+
39
+ <reference name="left">
40
+ <block type="mybrand/adminhtml_manufacturer_edit_tabs" name="mybrand_manufacturer_edit_tabs">
41
+ <block type="mybrand/adminhtml_manufacturer_edit_tab_general" name="mybrand_manufacturer_edit_tab_general" />
42
+ <block type="mybrand/adminhtml_manufacturer_edit_tab_meta" name="mybrand_manufacturer_edit_tab_meta" />
43
+
44
+ <block type="mybrand/adminhtml_manufacturer_edit_tab_product" name="mybrand_manufacturer_edit_tab_product" template="displaze/mybrand/manufacturer/edit/tab/product.phtml" >
45
+
46
+ <block type="mybrand/adminhtml_manufacturer_edit_tab_product_grid" name="mybrand_manufacturer_edit_tab_product_grid" as="product_grid" />
47
+ </block>
48
+
49
+
50
+
51
+ <action method="addTab"><name>general_section</name><block>mybrand_manufacturer_edit_tab_general</block></action>
52
+ <action method="addTab"><name>meta_section</name><block>mybrand_manufacturer_edit_tab_meta</block></action>
53
+ <action method="addTab"><name>product_section</name><block>mybrand_manufacturer_edit_tab_product</block></action>
54
+ </block>
55
+ </reference>
56
+
57
+ </adminhtml_manufacturer_edit>
58
+
59
+ </layout>
app/design/adminhtml/default/default/template/displaze/mybrand/manufacturer/edit/tab/product.phtml ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Renegade Group
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 Renegade
22
+ * @copyright Copyright (c) 2008-2011 Renegade Group (http://www.renegadefurniture.com)
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ */
25
+ ?>
26
+ <div class="entry-edit">
27
+ <div class="entry-edit-head">
28
+ <h4><?php echo $this->__('Products') ?></h4>
29
+ <div class="right"><?php echo $this->getAddButtonHtml(); ?></div>
30
+ </div>
31
+ <div id="product_box" class="box">
32
+ <div id="productGrid">
33
+ <div class="entry-edit">
34
+ <div class="entry-edit-head">
35
+ <div style="float: right;"><?php echo $this->getAddSelectedProductButtonHtml() ?></div>
36
+ <h4 class="fieldset-legend <?php echo ($this->getHeaderCssClass()) ? $this->getHeaderCssClass().' icon-head' : '' ?>"><?php echo $this->getHeaderText() ?></h4>
37
+ </div>
38
+ <?php echo $this->getChildHtml('product_grid'); ?>
39
+ </div>
40
+ </div>
41
+
42
+ <div class="grid tier form-list" id="box">
43
+ <table class="border" cellpadding="0" cellspacing="0" id="input-container">
44
+ <thead>
45
+ <tr class="headings">
46
+ <th><?php echo $this->__('ID') ?></th>
47
+ <th><?php echo $this->__('Name') ?></th>
48
+ <th><?php echo $this->__('SKU') ?></th>
49
+ <th><?php echo $this->__('Type') ?></th>
50
+ <th class="last"><?php echo $this->__('Delete') ?></th>
51
+ </tr>
52
+ </thead>
53
+ <tbody>
54
+ <?php $count = 0; foreach($this->getManufacturerProductCollection() as $_product): ?>
55
+ <tr id="product_entity_id_<?php echo $_product->getId(); ?>" class="selection">
56
+ <td>
57
+ <input type="hidden" value="<?php echo $_product->getId(); ?>" name="product[<?php echo $count; ?>][product_id]" id="product[<?php echo $count; ?>][product_id]">
58
+ <input type="hidden" value="<?php echo $_product->getSku(); ?>"name="product[<?php echo $count; ?>][product_sku]" id="product[<?php echo $count; ?>][product_sku]">
59
+ <?php echo $_product->getId(); ?>
60
+ </td>
61
+ <td>
62
+ <div class="nobr"><?php echo $_product->getName(); ?></div>
63
+ </td>
64
+ <td>
65
+ <div class="nobr"><?php echo $_product->getSku(); ?></div>
66
+ </td>
67
+ <td>
68
+ <?php echo $_product->getTypeId(); ?>
69
+ </td>
70
+
71
+ <td class="last">
72
+ <span title="Delete Row">
73
+ <button style="" class="scalable delete icon-btn" onclick="brandProduct.remove(this)" type="button">
74
+ <span>Delete</span>
75
+ </button>
76
+ </span>
77
+ </td>
78
+ </tr>
79
+ <?php $count++; endforeach; ?>
80
+ </tbody>
81
+ </table>
82
+ </div>
83
+ </div>
84
+
85
+
86
+
87
+
88
+ </div>
89
+ <script type="text/javascript">
90
+ //<![CDATA[
91
+ <?php echo $this->getChild('product_grid')->getJsObjectName(); ?>.checkboxCheckCallback = <?php echo $this->getChild('product_grid')->getCheckboxCheckCallback(); ?>
92
+
93
+ var productsGridElement = $('productGrid');
94
+ productsGridElement.hide();
95
+ $('product_add_button').observe('click', function (event) {
96
+ var element = event.element();
97
+ productsGridElement.visible() ? productsGridElement.hide() : productsGridElement.show();
98
+ });
99
+ //]]>
100
+ </script>
101
+
102
+ <script type="text/javascript">
103
+ // re-bind form elements onchange
104
+ //<![CDATA[
105
+ varienWindowOnload(true);
106
+ var productTemplateBox = '<table class="border" cellpadding="0" cellspacing="0">' +
107
+ ' <thead>' +
108
+ ' <tr class="headings">' +
109
+ ' <th><?php echo $this->__('ID') ?></th>' +
110
+ ' <th><?php echo $this->__('Name') ?></th>' +
111
+ ' <th><?php echo $this->__('SKU') ?></th>' +
112
+ ' <th><?php echo $this->__('Type') ?></th>' +
113
+ ' <th class="last"><?php echo $this->__('Delete') ?></th>' +
114
+ ' </tr>' +
115
+ ' </thead> ' +
116
+ ' <tbody>' +
117
+ ' </tbody>' +
118
+ '</table>';
119
+ var productTemplateRow = '<td>' +
120
+ ' <input type="hidden" value="{{product_id}}" name="product[{{index}}][product_id]" id="product[{{index}}][product_id]">' +
121
+ ' <input type="hidden" value="{{product_sku}}" name="product[{{index}}][product_sku]" id="product[{{index}}][product_sku]">' +
122
+ '<div class="nobr">{{product_id}}</div>' +
123
+ '</td>' +
124
+ '<td>' +
125
+ ' <div class="nobr">{{product_name}}</div>' +
126
+ '</td>' +
127
+ '<td>' +
128
+ ' <div class="nobr">{{product_sku}}</div>' +
129
+ '</td>' +
130
+ '<td>' +
131
+ ' {{product_type}}' +
132
+ '</td>' +
133
+
134
+ '<td class="last">' +
135
+ ' <span title="Delete Row">' +
136
+ ' <?php echo $this->getDeleteButtonHtml() ?>' +
137
+ ' </span>' +
138
+ '</td>' ;
139
+
140
+ Product = Class.create();
141
+ Product.prototype = {
142
+
143
+ templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
144
+ templateBox : '',
145
+ templateRow : '',
146
+ itemsCount : <?php echo $count; ?>,
147
+ row : null,
148
+
149
+ gridSelection : new Hash(),
150
+
151
+ initialize : function() {
152
+ this.templateBox = '<div class="grid tier form-list" id="box">' + productTemplateBox + '</div>';
153
+ this.templateRow = '<tr id="product_entity_id_{{product_id}}" class="selection">' + productTemplateRow + '</tr>';
154
+ },
155
+
156
+ showGridBox : function(event) {
157
+ this.gridSelection.unset(0);
158
+ new Ajax.Updater(
159
+ 'productGrid',
160
+ '<?php echo $this->getProductGridContainerUrl() ?>',
161
+ {
162
+ method: 'post',
163
+ evalScripts : true,
164
+ onSuccess: function() {
165
+ $('loading-mask').hide();
166
+
167
+ if (Event.element(event).tagName.toLowerCase() != 'button') {var button = Event.element(event).up('button');} else {var button = Event.element(event);}
168
+ button.hide();
169
+ }
170
+ }
171
+ );
172
+ },
173
+
174
+ addRow : function (data) {
175
+ var box = null;
176
+ if (!(box = $('box'))) {
177
+ this.addBox('product_box');
178
+ box = $('box');
179
+ } else {
180
+ box.show();
181
+ }
182
+ if(!data){
183
+ var data = {};
184
+ }
185
+ data.index = this.itemsCount++;
186
+ this.template = new Template(this.templateRow, this.templateSyntax);
187
+ var tbody = $$('#box tbody');
188
+ Element.insert(tbody[0], {'bottom':this.template.evaluate(data)});
189
+ },
190
+ productGridCheckboxCheck : function(element) {
191
+ var tr = element.up('tr');
192
+
193
+ if (element.value > 0) {
194
+ if (element.checked) {
195
+ if (!this.gridSelection.get(0)) {
196
+ this.gridSelection.set(0, new Hash());
197
+ }
198
+ this.gridSelection.get(0).set(element.value, $H({}));
199
+ this.gridSelection.get(0).get(element.value).set('product_name', tr.select('td.product_name')[0].innerHTML);
200
+ this.gridSelection.get(0).get(element.value).set('product_id', element.value);
201
+ this.gridSelection.get(0).get(element.value).set('product_sku', tr.select('td.product_sku')[0].innerHTML);
202
+ this.gridSelection.get(0).get(element.value).set('product_type', tr.select('td.product_type')[0].innerHTML);
203
+ }else{
204
+ if(this.gridSelection.get(0).get(element.value)){
205
+ this.gridSelection.get(0).unset(element.value);
206
+ }
207
+ }
208
+
209
+ }
210
+ },
211
+ productGridAddSelected : function(event) {
212
+ $('productGrid').hide();
213
+ $('product_add_button').show();
214
+ if(this.gridSelection.get(0))
215
+ {
216
+ this.gridSelection.get(0).each(
217
+ function(pair) {
218
+ var data = {
219
+ 'product_name' : pair.value.get('product_name').trim(),
220
+ 'product_id' : pair.value.get('product_id').trim(),
221
+ 'product_sku' : pair.value.get('product_sku').trim(),
222
+ 'product_type' : pair.value.get('product_type').trim()
223
+ };
224
+ if($('product_entity_id_'+data.product_id) == undefined)
225
+ {
226
+ brandProduct.addRow(data);
227
+ }
228
+ }
229
+ );
230
+ }
231
+ },
232
+
233
+ remove : function(element) {
234
+ tr = element.up('tr');
235
+ tr.remove();
236
+ },
237
+
238
+ addBox : function (parentIndex) {
239
+ var div = $(parentIndex)
240
+ this.template = new Template(this.templateBox, this.templateSyntax);
241
+ var data = {};
242
+ Element.insert(div, {'bottom':this.template.evaluate(data)});
243
+ }
244
+ }
245
+ var brandProduct = new Product();
246
+ //]]>
247
+ </script>
app/design/adminhtml/default/default/template/displaze/mybrand/manufacturer/edit/tab/product/grid.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Renegade Group
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 Renegade
22
+ * @copyright Copyright (c) 2008-2011 Renegade Group (http://www.renegadefurniture.com)
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ */
app/design/adminhtml/default/default/template/displaze/mybrand/manufacturer/edit/tab/product/list.phtml ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Renegade Group
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 Renegade
22
+ * @copyright Copyright (c) 2008-2011 Renegade Group (http://www.renegadefurniture.com)
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ */
25
+ ?>
26
+ <div class="entry-edit">
27
+ <div class="entry-edit-head">
28
+ <h4><?php echo $this->__('Products') ?></h4>
29
+ <div class="right"><?php echo $this->getProductAddButtonHtml(); ?></div>
30
+ </div>
31
+ <div id="product_box" class="box">
32
+ <div id="productGrid"><!--Load grid Here--></div>
33
+ <?php $i = 0;
34
+ if (isset($_familyProducts) && count($_familyProducts)>0 && $_familyProducts!=false): ?>
35
+ <div class="grid tier form-list" id="box">
36
+ <table class="border" cellpadding="0" cellspacing="0" id="input-container">
37
+ <thead>
38
+ <tr class="headings">
39
+ <th><?php echo $this->__('ID') ?></th>
40
+ <th><?php echo $this->__('Name') ?></th>
41
+ <th><?php echo $this->__('SKU') ?></th>
42
+ <th><?php echo $this->__('Type') ?></th>
43
+ <th><?php echo $this->__('Product ID') ?></th>
44
+ <th class="last"><?php echo $this->__('Delete') ?></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <?php foreach ((array)$_familyProducts as $_familyProduct): ?>
49
+ <tr id="product_entity_id_<?php echo $_familyProduct->getEntityId(); ?>" class="selection">
50
+ <td>
51
+ <input type="hidden" value="<?php echo $_familyProduct->getEntityId(); ?>" name="family_product[<?php echo $i; ?>][product_id]" id="family_product[<?php echo $i; ?>][product_id]">
52
+ <input type="hidden" value="<?php echo $_familyProduct->getSku(); ?>" name="family_product[<?php echo $i; ?>][product_sku]" id="family_product[<?php echo $i; ?>][product_sku]">
53
+ <input type="hidden" value="<?php echo $_familyProduct->getMyProductFamilyContentId(); ?>" name="family_product[<?php echo $i; ?>][product_family_content_id]" id="family_product[<?php echo $i; ?>][product_family_content_id]">
54
+
55
+ <?php echo $_familyProduct->getMyProductFamilyContentId(); ?>
56
+ </td>
57
+ <td>
58
+ <div class="nobr"><?php echo $_familyProduct->getName(); ?></div>
59
+ </td>
60
+ <td>
61
+ <div class="nobr"><?php echo $_familyProduct->getSku(); ?></div>
62
+ </td>
63
+ <td>
64
+ <?php echo $_familyProduct->getTypeId(); ?>
65
+ </td>
66
+ <td>
67
+ <?php echo $_familyProduct->getEntityId(); ?>
68
+ </td>
69
+
70
+ <td class="last">
71
+ <span title="Delete Row">
72
+ <button style="" class="scalable delete icon-btn" onclick="manageProduct.remove(this)" type="button">
73
+ <span>Delete</span>
74
+ </button>
75
+ </span>
76
+ </td>
77
+ </tr>
78
+ <?php $i++; ?>
79
+ <?php endforeach; ?>
80
+ </tbody>
81
+ </table>
82
+
83
+ </div>
84
+ <?php endif; ?>
85
+ </div>
86
+ </div>
87
+
88
+
89
+
90
+ <script type="text/javascript">
91
+ // re-bind form elements onchange
92
+ //<![CDATA[
93
+ varienWindowOnload(true);
94
+ var productTemplateBox = '<table class="border" cellpadding="0" cellspacing="0">' +
95
+ ' <thead>' +
96
+ ' <tr class="headings">' +
97
+ ' <th><?php echo $this->__('ID') ?></th>' +
98
+ ' <th><?php echo $this->__('Name') ?></th>' +
99
+ ' <th><?php echo $this->__('SKU') ?></th>' +
100
+ ' <th><?php echo $this->__('Type') ?></th>' +
101
+ ' <th><?php echo $this->__('Product ID') ?></th>' +
102
+ ' <th class="last"><?php echo $this->__('Delete') ?></th>' +
103
+ ' </tr>' +
104
+ ' </thead> ' +
105
+ ' <tbody>' +
106
+ ' </tbody>' +
107
+ '</table>';
108
+ var productTemplateRow = '<td>' +
109
+ ' <input type="hidden" value="{{product_id}}" name="family_product[{{index}}][product_id]" id="family_product[{{index}}][product_id]">' +
110
+ ' <input type="hidden" value="{{product_sku}}" name="family_product[{{index}}][product_sku]" id="family_product[{{index}}][product_sku]">' +
111
+ ' &nbsp;' +
112
+ '</td>' +
113
+ '<td>' +
114
+ ' <div class="nobr">{{product_name}}</div>' +
115
+ '</td>' +
116
+ '<td>' +
117
+ ' <div class="nobr">{{product_sku}}</div>' +
118
+ '</td>' +
119
+ '<td>' +
120
+ ' {{product_type}}' +
121
+ '</td>' +
122
+ '<td>' +
123
+ ' {{product_id}}' +
124
+ '</td>' +
125
+ '<td class="last">' +
126
+ ' <span title="Delete Row">' +
127
+ ' <?php echo $this->getProductDeleteButtonHtml() ?>' +
128
+ ' </span>' +
129
+ '</td>' ;
130
+
131
+ Product = Class.create();
132
+ Product.prototype = {
133
+
134
+ templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
135
+ templateBox : '',
136
+ templateRow : '',
137
+ itemsCount : <? echo $i; ?>,
138
+ row : null,
139
+
140
+ gridSelection : new Hash(),
141
+
142
+ initialize : function() {
143
+ this.templateBox = '<div class="grid tier form-list" id="box">' + productTemplateBox + '</div>';
144
+ this.templateRow = '<tr id="product_entity_id_{{product_id}}" class="selection">' + productTemplateRow + '</tr>';
145
+ },
146
+
147
+ showGridBox : function(event) {
148
+ this.gridSelection.unset(0);
149
+ new Ajax.Updater(
150
+ 'productGrid',
151
+ '<?php echo $this->getProductGridContainerUrl() ?>',
152
+ {
153
+ method: 'post',
154
+ evalScripts : true,
155
+ onSuccess: function() {
156
+ $('loading-mask').hide();
157
+
158
+ if (Event.element(event).tagName.toLowerCase() != 'button') {var button = Event.element(event).up('button');} else {var button = Event.element(event);}
159
+ button.hide();
160
+ }
161
+ }
162
+ );
163
+ },
164
+
165
+ addRow : function (data) {
166
+ var box = null;
167
+ if (!(box = $('box'))) {
168
+ this.addBox('product_box');
169
+ box = $('box');
170
+ } else {
171
+ box.show();
172
+ }
173
+ if(!data){
174
+ var data = {};
175
+ }
176
+ data.index = this.itemsCount++;
177
+ this.template = new Template(this.templateRow, this.templateSyntax);
178
+ var tbody = $$('#box tbody');
179
+ Element.insert(tbody[0], {'bottom':this.template.evaluate(data)});
180
+ },
181
+ productGridCheckboxCheck : function(element) {
182
+ var tr = element.up('tr');
183
+
184
+ if (element.value > 0) {
185
+ if (element.checked) {
186
+ if (!this.gridSelection.get(0)) {
187
+ this.gridSelection.set(0, new Hash());
188
+ }
189
+ this.gridSelection.get(0).set(element.value, $H({}));
190
+ this.gridSelection.get(0).get(element.value).set('product_name', tr.select('td.product_name')[0].innerHTML);
191
+ this.gridSelection.get(0).get(element.value).set('product_id', element.value);
192
+ this.gridSelection.get(0).get(element.value).set('product_sku', tr.select('td.product_sku')[0].innerHTML);
193
+ this.gridSelection.get(0).get(element.value).set('product_type', tr.select('td.product_type')[0].innerHTML);
194
+ }else{
195
+ if(this.gridSelection.get(0).get(element.value)){
196
+ this.gridSelection.get(0).unset(element.value);
197
+ }
198
+ }
199
+
200
+ }
201
+ },
202
+ productGridAddSelected : function(event) {
203
+ $('productGrid').innerHTML = '';
204
+ $('add_product_button').show();
205
+ if(this.gridSelection.get(0))
206
+ {
207
+ this.gridSelection.get(0).each(
208
+ function(pair) {
209
+ var data = {
210
+ 'product_name' : pair.value.get('product_name').trim(),
211
+ 'product_id' : pair.value.get('product_id').trim(),
212
+ 'product_sku' : pair.value.get('product_sku').trim(),
213
+ 'product_type' : pair.value.get('product_type').trim()
214
+ };
215
+ if($('product_entity_id_'+data.product_id) == undefined)
216
+ {
217
+ manageProduct.addRow(data);
218
+ }
219
+ }
220
+ );
221
+ }
222
+ },
223
+
224
+ remove : function(element) {
225
+ tr = element.up('tr');
226
+ tr.remove();
227
+ },
228
+
229
+ addBox : function (parentIndex) {
230
+ var div = $(parentIndex)
231
+ this.template = new Template(this.templateBox, this.templateSyntax);
232
+ var data = {};
233
+ Element.insert(div, {'bottom':this.template.evaluate(data)});
234
+ }
235
+ }
236
+ manageProduct = new Product();
237
+ //]]>
238
+ </script>
app/design/adminhtml/default/default/template/displaze/mybrand/manufacturer/tab.phtml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * tab.phtml
4
+ *
5
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+ *
7
+ * This file is part of Displaze Web Services Inc..
8
+ *
9
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ */
22
+ ?>
23
+ <div class="entry-edit">
24
+ <div class="entry-edit-head">
25
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Manufacturer'); ?></h4>
26
+ </div>
27
+ <div id="group_fields4" class="fieldset fieldset-wide">
28
+ <div class="hor-scroll">
29
+ <table cellspacing="0" class="form-list">
30
+ <tbody>
31
+ <tr>
32
+ <td>
33
+ <table cellspacing="0" class="form-list">
34
+ <tbody>
35
+ <tr>
36
+ <td class="label">
37
+ <label for="enablenew">
38
+ <?php echo $this->__('Select Manufacturer'); ?>
39
+ </label>
40
+ </td>
41
+ <td class="value">
42
+
43
+
44
+ <select class=" select" name="manufacturers_id" id="manufacturer_id">
45
+ <option value="0"><?php echo $this->__('No Manufacturer'); ?></option>
46
+ <?php foreach ($this->getManufacturerCollection() as $_manufacturer) : ?>
47
+ <?php if ($this->getProduct()->getManufacturerId() == $_manufacturer->getId()): ?>
48
+ <option selected="selected" value="<?php echo $_manufacturer->getId(); ?>">
49
+ <?php echo $_manufacturer->getTitle(); ?>
50
+ </option>
51
+ <?php else: ?>
52
+ <option value="<?php echo $_manufacturer->getId(); ?>">
53
+ <?php echo $_manufacturer->getTitle(); ?>
54
+ </option>
55
+ <?php endif; ?>
56
+
57
+ <?php endforeach; ?>
58
+ </select>
59
+ </td>
60
+ <td class="scope-label"><span class="nobr"></span></td>
61
+ <td><small>&nbsp;</small></td>
62
+ </tr>
63
+ </tbody>
64
+ </table>
65
+ </td>
66
+ </tr>
67
+ </tbody>
68
+ </table>
69
+ </div>
70
+ </div>
71
+ </div>
app/design/frontend/default/default/layout/displaze/mybrand.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ mybrand.xml
4
+
5
+ Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+
7
+ This file is part of Displaze Web Services Inc..
8
+
9
+ Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ -->
22
+
23
+ <layout version="0.1.0">
24
+ <!--
25
+ Default layout, get manufactuerer and its products
26
+ -->
27
+ <mybrand_manufacturer_view translate="label">
28
+
29
+ <reference name="content">
30
+ <block type="mybrand/manufacturer" name="manufacturer_view" template="displaze/mybrand/manufacturer/view.phtml" >
31
+ <block type="mybrand/manufacturer_product_list" name="manufacturer_product_list" template="catalog/product/list.phtml"/>
32
+ </block>
33
+ </reference>
34
+ </mybrand_manufacturer_view>
35
+ </layout>
app/design/frontend/default/default/template/displaze/mybrand/manufacturer/link.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * link.phtml
4
+ *
5
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+ *
7
+ * This file is part of Displaze Web Services Inc..
8
+ *
9
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ */
22
+ ?>
23
+
24
+ <!--Code to include shopby brand menu -->
25
+ <?php $manufacturerCollection = $this->getManufacturerCollection(); ?>
26
+ <?php if (count($manufacturerCollection) != 0) : ?>
27
+ <li class="current shop-by-brand">
28
+ <a href="#"><?php echo $this->__('Shop By Brand') ?></a>
29
+ <ul>
30
+ <?php foreach ($manufacturerCollection as $_manufacturer) : ?>
31
+ <li>
32
+ <a href="<?php echo Mage::helper('mybrand/manufacturer')->getUrl($_manufacturer->getIdentifier()); ?>" class="">
33
+ <span><?php echo $this->htmlEscape($_manufacturer->getTitle()) ?></span>
34
+ </a>
35
+ </li>
36
+ <?php endforeach ?>
37
+ </ul>
38
+ </li>
39
+ <?php endif; ?>
app/design/frontend/default/default/template/displaze/mybrand/manufacturer/view.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * view.phtml
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+ $_manufacturer = $this->getManufacturer();
24
+ ?>
25
+ <?php
26
+ /**
27
+ * @see Displaze_MyBrand_Block_Adminhtml_Manufacturer
28
+ */
29
+ ?>
30
+
31
+ <h1><?php echo $_manufacturer->getTitle(); ?></h1>
32
+
33
+ <div class="description">
34
+ <?php if(file_exists(Mage::helper('mybrand')->getBrandMediaPath() . $_manufacturer->getLogo())): ?>
35
+ <img src="<?php echo Mage::helper('mybrand')->getBrandMediaUrl() . $_manufacturer->getLogo() ?>" />
36
+ <?php endif; ?>
37
+ <?php echo $_manufacturer->getContent(); ?>
38
+ </div>
39
+
40
+ <?php echo $this->getChildHtml('manufacturer_product_list'); //display products associated with this manufacturer ?>
app/design/frontend/default/default/template/displaze/mybrand/page/html/topmenu.phtml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * top.phtml
5
+ *
6
+ * Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
7
+ *
8
+ * This file is part of Displaze Web Services Inc..
9
+ *
10
+ * Displaze Web Services Inc. is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Displaze Web Services Inc. is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
22
+ */
23
+ ?>
24
+ <?php
25
+ /**
26
+ * Top menu for store
27
+ *
28
+ * @see Displaze_MyBrand_Block_Page_Html_Topmenu
29
+ */
30
+ ?>
31
+ <?php $_menu = $this->getHtml('level-top') ?>
32
+ <?php if($_menu): ?>
33
+ <div class="nav-container">
34
+ <ul id="nav">
35
+ <?php echo $_menu ?>
36
+ <!--Code to include shopby brand menu -->
37
+ <?php $manufacturerCollection = $this->getManufacturerCollection(); ?>
38
+ <?php if ( count($manufacturerCollection) != 0 ) : ?>
39
+ <li class="current shop-by-brand">
40
+ <a href="#"><?php echo $this->__('Shop By Brand') ?></a>
41
+ <ul>
42
+ <?php foreach ( $manufacturerCollection as $_manufacturer ) : ?>
43
+ <li>
44
+ <a href="<?php echo Mage::helper('mybrand/manufacturer')->getUrl($_manufacturer->getIdentifier()); ?>" class="">
45
+ <span><?php echo $this->htmlEscape($_manufacturer->getTitle()) ?></span>
46
+ </a>
47
+ </li>
48
+ <?php endforeach ?>
49
+ </ul>
50
+ </li>
51
+ <?php endif; ?>
52
+ </ul>
53
+ </div>
54
+ <?php endif ?>
app/etc/modules/Displaze_MyBrand.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ Displaze_MyBrand.xml
4
+
5
+ Copyright (c) 2012 Aftab Naveed <aftabnaveed@gmail.com>.
6
+
7
+ This file is part of Displaze Web Services Inc..
8
+
9
+ Displaze Web Services Inc. is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ Displaze Web Services Inc. is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with Displaze Web Services Inc.. If not, see <http ://www.gnu.org/licenses/>.
21
+ -->
22
+
23
+ <config>
24
+ <modules>
25
+ <Displaze_MyBrand>
26
+ <codePool>community</codePool>
27
+ <active>true</active>
28
+ <depends>
29
+ <Mage_Catalog />
30
+ </depends>
31
+ </Displaze_MyBrand>
32
+ </modules>
33
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Displaze_MyBrand</name>
4
+ <version>1.7.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Displaze MyBrand gives your shoppers instant access to manufacturer products </summary>
10
+ <description>Displaze MyBrand gives your shoppers instant access to manufacturer products, it is free and opensource</description>
11
+ <notes>First Stable Release</notes>
12
+ <authors><author><name>Aftab Naveed</name><user>aftabnaveed</user><email>aftabnaveed@gmail.com</email></author></authors>
13
+ <date>2012-07-22</date>
14
+ <time>11:47:54</time>
15
+ <contents><target name="magecommunity"><dir name="Displaze"><dir name="MyBrand"><dir name="Block"><dir name="Adminhtml"><dir name="Image"><file name="Renderer.php" hash="8bc0e082565e59943baaa8e39e3c85d8"/></dir><dir name="Manufacturer"><dir name="Edit"><file name="Form.php" hash="b694133a972c0801068b94a0523cf8d8"/><dir name="Tab"><file name="General.php" hash="7321e4239adc4f3696b9aa4fd0b030d8"/><file name="Meta.php" hash="852937707edf3550fe63e8eab71b9432"/><dir name="Product"><file name="Grid.php" hash="2db41d34fb206d3edde1994e3b5f56f8"/><file name="List.php" hash="d06f56078f12d82ab1cec3bc97478a47"/></dir><file name="Product.php" hash="af5819920b0596028b2d1656b2f480f3"/></dir><file name="Tabs.php" hash="d12260d9da9d56f5c1a3690064153a53"/></dir><file name="Edit.php" hash="1a00125328032354e265535321d9e6b9"/><file name="Grid.php" hash="4bcf6887c4c89fdbe90019b7cc285479"/><file name="Tab.php" hash="741a9f8e4537c06935d377fe42ba4016"/></dir><file name="Manufacturer.php" hash="504333fae1a7f48f730c48077c4494a3"/><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Checkbox.php" hash="5cb080de10620fc1108229bb0e9da5ab"/></dir></dir></dir></dir></dir><dir name="Manufacturer"><file name="Link.php" hash="e3189e3ce351f1cc9974b1e0345f4288"/><dir name="Product"><file name="List.php" hash="3d0c5456cce0a8519a64cf731c0d8758"/></dir></dir><file name="Manufacturer.php" hash="0c6c1ba3224bf04ee018c84f7447f2b3"/><dir name="Page"><dir name="Html"><file name="Topmenu.php" hash="d9a7f83d31cc7c89cdf0d66015222f60"/></dir></dir></dir><dir name="Controller"><file name="Router.php" hash="05affe78343c8e5fa912c60d89aca5f4"/></dir><dir name="Helper"><file name="Data.php" hash="6d007dbf1f6b10f5ef3bdd94d6d21a10"/><file name="Manufacturer.php" hash="038dcf718a160f2bfcf4399f56b857df"/></dir><dir name="Model"><dir name="Manufacturer"><file name="Product.php" hash="56fe06945698cbde7c78e4c011576766"/></dir><file name="Manufacturer.php" hash="55c0465c27436e4513e3cbe6437859db"/><dir name="Observer"><file name="Product.php" hash="e2f09048c9cf25287770fc26e152e682"/></dir><dir name="Resource"><dir name="Manufacturer"><file name="Collection.php" hash="e9b2a64f401ba6e1e29efa188b5887e6"/><file name="Product.php" hash="571f00dc64db1fab039bedd7fed050fb"/></dir><file name="Manufacturer.php" hash="e56c0a52cfe7a4dc1c95f8f819d8898a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ManufacturerController.php" hash="eb5fdb01eed16c780652946df626f469"/></dir><file name="ManufacturerController.php" hash="b7e7182a34327b6e18d794f636546daa"/></dir><dir name="etc"><file name="adminhtml.xml" hash="cefb5ba97c48e1e17145e9c4bc1ed04e"/><file name="config.xml" hash="840cb2e87ff3c0e099906830e6569788"/></dir><dir name="sql"><dir name="mybrand_setup"><file name="install-1.7.0.php" hash="1eacf2893bd051918a72dcc34c4de1dc"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Displaze_MyBrand.xml" hash="1173db92c9fce40b6f4be5591d8ce9fe"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="displaze"><file name="mybrand.xml" hash="0ae2e7613986877efbe6a943d8783dc1"/></dir></dir><dir name="template"><dir name="displaze"><dir name="mybrand"><dir name="manufacturer"><dir name="edit"><dir name="tab"><dir name="product"><file name="grid.phtml" hash="0806869656d8c2c4385c0fabc31afdde"/><file name="list.phtml" hash="bc3ac028524c71e062d672fdedb3db8f"/></dir><file name="product.phtml" hash="20fa1195628465170118c80ce7c7c5e2"/></dir></dir><file name="tab.phtml" hash="f542a5a18da1af62c46331a810383f6a"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="displaze"><file name="mybrand.xml" hash="035fd3a8998f1bffd7c4cd28bb8813df"/></dir></dir><dir name="template"><dir name="displaze"><dir name="mybrand"><dir name="manufacturer"><file name="link.phtml" hash="2f54e11b47ed47ccf10a6b695a411f4f"/><file name="view.phtml" hash="babc2b63c36676433ba5b8db976c06c7"/></dir><dir name="page"><dir name="html"><file name="topmenu.phtml" hash="bc646d96f406fadb2c04bda2a8e44e58"/></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>